1*e1fe3e4aSElliott Hughestry: 2*e1fe3e4aSElliott Hughes from fontTools.misc.symfont import AreaPen 3*e1fe3e4aSElliott Hughesexcept ImportError: 4*e1fe3e4aSElliott Hughes AreaPen = None 5*e1fe3e4aSElliott Hughesimport unittest 6*e1fe3e4aSElliott Hughesimport pytest 7*e1fe3e4aSElliott Hughes 8*e1fe3e4aSElliott Hughesprecision = 6 9*e1fe3e4aSElliott Hughes 10*e1fe3e4aSElliott Hughes 11*e1fe3e4aSElliott Hughesdef draw1_(pen): 12*e1fe3e4aSElliott Hughes pen.moveTo((254, 360)) 13*e1fe3e4aSElliott Hughes pen.lineTo((771, 367)) 14*e1fe3e4aSElliott Hughes pen.curveTo((800, 393), (808, 399), (819, 412)) 15*e1fe3e4aSElliott Hughes pen.curveTo((818, 388), (774, 138), (489, 145)) 16*e1fe3e4aSElliott Hughes pen.curveTo((188, 145), (200, 398), (200, 421)) 17*e1fe3e4aSElliott Hughes pen.curveTo((209, 409), (220, 394), (254, 360)) 18*e1fe3e4aSElliott Hughes pen.closePath() 19*e1fe3e4aSElliott Hughes 20*e1fe3e4aSElliott Hughes 21*e1fe3e4aSElliott Hughesclass AreaPenTest(unittest.TestCase): 22*e1fe3e4aSElliott Hughes @pytest.mark.skipif(AreaPen is None, reason="sympy not installed") 23*e1fe3e4aSElliott Hughes def test_PScontour_clockwise_line_first(self): 24*e1fe3e4aSElliott Hughes pen = AreaPen(glyphset=None) 25*e1fe3e4aSElliott Hughes draw1_(pen) 26*e1fe3e4aSElliott Hughes self.assertEqual(-104561.35, round(pen.value, precision)) 27*e1fe3e4aSElliott Hughes 28*e1fe3e4aSElliott Hughes @pytest.mark.skipif(AreaPen is None, reason="sympy not installed") 29*e1fe3e4aSElliott Hughes def test_openPaths(self): 30*e1fe3e4aSElliott Hughes pen = AreaPen() 31*e1fe3e4aSElliott Hughes pen.moveTo((0, 0)) 32*e1fe3e4aSElliott Hughes pen.endPath() 33*e1fe3e4aSElliott Hughes self.assertEqual(0, pen.value) 34*e1fe3e4aSElliott Hughes 35*e1fe3e4aSElliott Hughes pen.moveTo((0, 0)) 36*e1fe3e4aSElliott Hughes pen.lineTo((1, 0)) 37*e1fe3e4aSElliott Hughes with self.assertRaises(NotImplementedError): 38*e1fe3e4aSElliott Hughes pen.endPath() 39*e1fe3e4aSElliott Hughes 40*e1fe3e4aSElliott Hughes 41*e1fe3e4aSElliott Hughesif __name__ == "__main__": 42*e1fe3e4aSElliott Hughes import sys 43*e1fe3e4aSElliott Hughes 44*e1fe3e4aSElliott Hughes sys.exit(unittest.main()) 45