diff options
Diffstat (limited to 'Tests/ufoLib/GLIF1_test.py')
-rw-r--r-- | Tests/ufoLib/GLIF1_test.py | 908 |
1 files changed, 459 insertions, 449 deletions
diff --git a/Tests/ufoLib/GLIF1_test.py b/Tests/ufoLib/GLIF1_test.py index 85fcc71f..c4991ca3 100644 --- a/Tests/ufoLib/GLIF1_test.py +++ b/Tests/ufoLib/GLIF1_test.py @@ -1,5 +1,9 @@ import unittest -from fontTools.ufoLib.glifLib import GlifLibError, readGlyphFromString, writeGlyphToString +from fontTools.ufoLib.glifLib import ( + GlifLibError, + readGlyphFromString, + writeGlyphToString, +) from .testSupport import Glyph, stripText from itertools import islice @@ -7,256 +11,262 @@ from itertools import islice # Test Cases # ---------- -class TestGLIF1(unittest.TestCase): - def assertEqual(self, first, second, msg=None): - if isinstance(first, str): - first = stripText(first) - if isinstance(second, str): - second = stripText(second) - return super().assertEqual(first, second, msg=msg) - - def pyToGLIF(self, py): - py = stripText(py) - glyph = Glyph() - exec(py, {"glyph" : glyph, "pointPen" : glyph}) - glif = writeGlyphToString(glyph.name, glyphObject=glyph, drawPointsFunc=glyph.drawPoints, formatVersion=1, validate=True) - # discard the first line containing the xml declaration - return "\n".join(islice(glif.splitlines(), 1, None)) - - def glifToPy(self, glif): - glif = stripText(glif) - glif = "<?xml version=\"1.0\"?>\n" + glif - glyph = Glyph() - readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph, validate=True) - return glyph.py() - - def testTopElement(self): - # not glyph - glif = """ +class TestGLIF1(unittest.TestCase): + def assertEqual(self, first, second, msg=None): + if isinstance(first, str): + first = stripText(first) + if isinstance(second, str): + second = stripText(second) + return super().assertEqual(first, second, msg=msg) + + def pyToGLIF(self, py): + py = stripText(py) + glyph = Glyph() + exec(py, {"glyph": glyph, "pointPen": glyph}) + glif = writeGlyphToString( + glyph.name, + glyphObject=glyph, + drawPointsFunc=glyph.drawPoints, + formatVersion=1, + validate=True, + ) + # discard the first line containing the xml declaration + return "\n".join(islice(glif.splitlines(), 1, None)) + + def glifToPy(self, glif): + glif = stripText(glif) + glif = '<?xml version="1.0"?>\n' + glif + glyph = Glyph() + readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph, validate=True) + return glyph.py() + + def testTopElement(self): + # not glyph + glif = """ <notglyph name="a" format="1"> <outline> </outline> </notglyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testName_legal(self): - # legal - glif = """ + def testName_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testName_empty(self): - # empty - glif = """ + def testName_empty(self): + # empty + glif = """ <glyph name="" format="1"> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "" """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testName_not_a_string(self): - # not a string - py = """ + def testName_not_a_string(self): + # not a string + py = """ glyph.name = 1 """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.pyToGLIF, py) - def testFormat_legal(self): - # legal - glif = """ + def testFormat_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testFormat_wrong_number(self): - # wrong number - glif = """ + def testFormat_wrong_number(self): + # wrong number + glif = """ <glyph name="a" format="-1"> <outline> </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testFormat_not_an_int(self): - # not an int - glif = """ + def testFormat_not_an_int(self): + # not an int + glif = """ <glyph name="a" format="A"> <outline> </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testBogusGlyphStructure_unknown_element(self): - # unknown element - glif = """ + def testBogusGlyphStructure_unknown_element(self): + # unknown element + glif = """ <glyph name="a" format="1"> <unknown /> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testBogusGlyphStructure_content(self): - # content - glif = """ + def testBogusGlyphStructure_content(self): + # content + glif = """ <glyph name="a" format="1"> Hello World. </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testAdvance_legal_width_and_height(self): - # legal: width and height - glif = """ + def testAdvance_legal_width_and_height(self): + # legal: width and height + glif = """ <glyph name="a" format="1"> <advance height="200" width="100"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.width = 100 glyph.height = 200 """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testAdvance_legal_width_and_height_floats(self): - # legal: width and height floats - glif = """ + def testAdvance_legal_width_and_height_floats(self): + # legal: width and height floats + glif = """ <glyph name="a" format="1"> <advance height="200.1" width="100.1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.width = 100.1 glyph.height = 200.1 """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testAdvance_legal_width(self): - # legal: width - glif = """ + def testAdvance_legal_width(self): + # legal: width + glif = """ <glyph name="a" format="1"> <advance width="100"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.width = 100 """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testAdvance_legal_height(self): - # legal: height - glif = """ + def testAdvance_legal_height(self): + # legal: height + glif = """ <glyph name="a" format="1"> <advance height="200"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.height = 200 """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testAdvance_illegal_width(self): - # illegal: not a number - glif = """ + def testAdvance_illegal_width(self): + # illegal: not a number + glif = """ <glyph name="a" format="1"> <advance width="a"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.width = "a" """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testAdvance_illegal_height(self): - glif = """ + def testAdvance_illegal_height(self): + glif = """ <glyph name="a" format="1"> <advance height="a"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.height = "a" """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testUnicodes_legal(self): - # legal - glif = """ + def testUnicodes_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <unicode hex="0061"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.unicodes = [97] """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testUnicodes_legal_multiple(self): - glif = """ + def testUnicodes_legal_multiple(self): + glif = """ <glyph name="a" format="1"> <unicode hex="0062"/> <unicode hex="0063"/> @@ -265,33 +275,33 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.unicodes = [98, 99, 97] """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testUnicodes_illegal(self): - # illegal - glif = """ + def testUnicodes_illegal(self): + # illegal + glif = """ <glyph name="a" format="1"> <unicode hex="1.1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "zzzzzz" glyph.unicodes = ["1.1"] """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testNote(self): - glif = """ + def testNote(self): + glif = """ <glyph name="a" format="1"> <note> \U0001F4A9 @@ -300,17 +310,17 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.note = "💩" """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testLib_legal(self): - glif = """ + def testLib_legal(self): + glif = """ <glyph name="a" format="1"> <outline> </outline> @@ -338,150 +348,150 @@ class TestGLIF1(unittest.TestCase): </lib> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.lib = {"dict" : {"hello" : "world"}, "float" : 2.5, "int" : 1, "list" : ["a", "b", 1, 2.5], "string" : "a"} """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testOutline_unknown_element(self): - # unknown element - glif = """ + def testOutline_unknown_element(self): + # unknown element + glif = """ <glyph name="a" format="1"> <outline> <unknown/> </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testOutline_content(self): - # content - glif = """ + def testOutline_content(self): + # content + glif = """ <glyph name="a" format="1"> <outline> hello </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testComponent_legal(self): - # legal - glif = """ + def testComponent_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, 3, 6, 5, 1, 4)]) """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testComponent_illegal_no_base(self): - # no base - glif = """ + def testComponent_illegal_no_base(self): + # no base + glif = """ <glyph name="a" format="1"> <outline> <component xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testComponent_bogus_transformation(self): - # bogus values in transformation - glif = """ + def testComponent_bogus_transformation(self): + # bogus values in transformation + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", ("a", 3, 6, 5, 1, 4)]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) - glif = """ + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, "a", 6, 5, 1, 4)]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) - glif = """ + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="2" xyScale="3" yxScale="a" yScale="5" xOffset="1" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, 3, "a", 5, 1, 4)]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) - glif = """ + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="a" xOffset="1" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, 3, 6, "a", 1, 4)]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) - glif = """ + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="a" yOffset="4"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, 3, 6, 5, "a", 4)]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) - glif = """ + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) + glif = """ <glyph name="a" format="1"> <outline> <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="a"/> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.addComponent(*["x", (2, 3, 6, 5, 1, "a")]) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testContour_legal_one_contour(self): - # legal: one contour - glif = """ + def testContour_legal_one_contour(self): + # legal: one contour + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -489,19 +499,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testContour_legal_two_contours(self): - # legal: two contours - glif = """ + def testContour_legal_two_contours(self): + # legal: two contours + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -515,7 +525,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) @@ -526,14 +536,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(10, 20)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testContour_illegal_unkonwn_element(self): - # unknown element - glif = """ + def testContour_illegal_unkonwn_element(self): + # unknown element + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -542,11 +552,11 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointCoordinates_legal_int(self): - # legal: int - glif = """ + def testPointCoordinates_legal_int(self): + # legal: int + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -556,21 +566,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"name" : "this is here so that the contour isn't seen as an anchor", "segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointCoordinates_legal_float(self): - # legal: float - glif = """ + def testPointCoordinates_legal_float(self): + # legal: float + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -580,21 +590,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1.1, -2.2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"name" : "this is here so that the contour isn't seen as an anchor", "segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointCoordinates_illegal_x(self): - # illegal: string - glif = """ + def testPointCoordinates_illegal_x(self): + # illegal: string + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -604,19 +614,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[("a", 2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"name" : "this is here so that the contour isn't seen as an anchor", "segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointCoordinates_illegal_y(self): - # legal: int - glif = """ + def testPointCoordinates_illegal_y(self): + # legal: int + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -626,19 +636,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, "a")], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"name" : "this is here so that the contour isn't seen as an anchor", "segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointTypeMove_legal(self): - # legal - glif = """ + def testPointTypeMove_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -648,21 +658,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeMove_legal_smooth(self): - # legal: smooth=True - glif = """ + def testPointTypeMove_legal_smooth(self): + # legal: smooth=True + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -672,21 +682,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : True}) pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeMove_illegal_not_at_start(self): - # illegal: not at start - glif = """ + def testPointTypeMove_illegal_not_at_start(self): + # illegal: not at start + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -696,19 +706,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointTypeLine_legal(self): - # legal - glif = """ + def testPointTypeLine_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -718,21 +728,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeLine_legal_start_of_contour(self): - # legal: start of contour - glif = """ + def testPointTypeLine_legal_start_of_contour(self): + # legal: start of contour + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -742,21 +752,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "line", "smooth" : False}) pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeLine_legal_smooth(self): - # legal: smooth=True - glif = """ + def testPointTypeLine_legal_smooth(self): + # legal: smooth=True + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -766,21 +776,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : True}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_legal(self): - # legal - glif = """ + def testPointTypeCurve_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -792,7 +802,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -801,14 +811,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_legal_start_of_contour(self): - # legal: start of contour - glif = """ + def testPointTypeCurve_legal_start_of_contour(self): + # legal: start of contour + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -819,7 +829,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) @@ -827,14 +837,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_legal_smooth(self): - # legal: smooth=True - glif = """ + def testPointTypeCurve_legal_smooth(self): + # legal: smooth=True + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -846,7 +856,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -855,14 +865,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : True}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_legal_no_off_curves(self): - # legal: no off-curves - glif = """ + def testPointTypeCurve_legal_no_off_curves(self): + # legal: no off-curves + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -872,21 +882,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_legal_1_off_curve(self): - # legal: 1 off-curve - glif = """ + def testPointTypeCurve_legal_1_off_curve(self): + # legal: 1 off-curve + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -897,7 +907,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -905,14 +915,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeCurve_illegal_3_off_curves(self): - # illegal: 3 off-curves - glif = """ + def testPointTypeCurve_illegal_3_off_curves(self): + # illegal: 3 off-curves + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -925,7 +935,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -935,12 +945,12 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointQCurve_legal(self): - # legal - glif = """ + def testPointQCurve_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -952,7 +962,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -961,14 +971,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointQCurve_legal_start_of_contour(self): - # legal: start of contour - glif = """ + def testPointQCurve_legal_start_of_contour(self): + # legal: start of contour + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -979,7 +989,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) @@ -987,14 +997,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointQCurve_legal_smooth(self): - # legal: smooth=True - glif = """ + def testPointQCurve_legal_smooth(self): + # legal: smooth=True + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1006,7 +1016,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1015,14 +1025,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : True}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointQCurve_legal_no_off_curves(self): - # legal: no off-curves - glif = """ + def testPointQCurve_legal_no_off_curves(self): + # legal: no off-curves + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1032,21 +1042,21 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointQCurve_legal_one_off_curve(self): - # legal: 1 off-curve - glif = """ + def testPointQCurve_legal_one_off_curve(self): + # legal: 1 off-curve + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1057,7 +1067,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1065,14 +1075,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointQCurve_legal_3_off_curves(self): - # legal: 3 off-curves - glif = """ + def testPointQCurve_legal_3_off_curves(self): + # legal: 3 off-curves + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1085,7 +1095,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1095,14 +1105,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testSpecialCaseQCurve(self): - # contour with no on curve - glif = """ + def testSpecialCaseQCurve(self): + # contour with no on curve + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1114,7 +1124,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"smooth" : False}) @@ -1123,14 +1133,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 0)], **{"smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeOffCurve_legal(self): - # legal - glif = """ + def testPointTypeOffCurve_legal(self): + # legal + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1142,7 +1152,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1151,14 +1161,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeOffCurve_legal_start_of_contour(self): - # legal: start of contour - glif = """ + def testPointTypeOffCurve_legal_start_of_contour(self): + # legal: start of contour + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1169,7 +1179,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) @@ -1177,14 +1187,14 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testPointTypeOffCurve_illegal_before_move(self): - # before move - glif = """ + def testPointTypeOffCurve_illegal_before_move(self): + # before move + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1194,19 +1204,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointTypeOffCurve_illegal_before_line(self): - # before line - glif = """ + def testPointTypeOffCurve_illegal_before_line(self): + # before line + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1216,19 +1226,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) pointPen.addPoint(*[(0, 0)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testPointTypeOffCurve_illegal_smooth(self): - # smooth=True - glif = """ + def testPointTypeOffCurve_illegal_smooth(self): + # smooth=True + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1238,20 +1248,20 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 65)], **{"smooth" : True}) pointPen.addPoint(*[(0, 0)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testSinglePoint_legal_without_name(self): - # legal - # glif format 1 single point without a name was not an anchor - glif = """ + def testSinglePoint_legal_without_name(self): + # legal + # glif format 1 single point without a name was not an anchor + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1260,19 +1270,19 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) pointPen.endPath() """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testAnchor_legal_with_name(self): - glif = """ + def testAnchor_legal_with_name(self): + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1281,18 +1291,18 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"name" : "test", "x" : 1, "y" : 2}] """ - resultGlif = self.pyToGLIF(py) - resultPy = self.glifToPy(glif) - self.assertEqual(glif, resultGlif) - self.assertEqual(py, resultPy) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) - def testOpenContourLooseOffCurves_legal(self): - # a piece of software was writing this kind of structure - glif = """ + def testOpenContourLooseOffCurves_legal(self): + # a piece of software was writing this kind of structure + glif = """ <glyph name="a" format="1"> <outline> <contour> @@ -1305,7 +1315,7 @@ class TestGLIF1(unittest.TestCase): </outline> </glyph> """ - expectedPy = """ + expectedPy = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) @@ -1314,11 +1324,11 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(1, 2)], **{"segmentType" : "curve", "smooth" : False}) pointPen.endPath() """ - resultPy = self.glifToPy(glif) - self.assertEqual(resultPy, expectedPy) + resultPy = self.glifToPy(glif) + self.assertEqual(resultPy, expectedPy) - def testOpenContourLooseOffCurves_illegal(self): - py = """ + def testOpenContourLooseOffCurves_illegal(self): + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) @@ -1328,4 +1338,4 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(1, 2)], **{"smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.pyToGLIF, py) |