diff options
Diffstat (limited to 'Tests/ufoLib/GLIF2_test.py')
-rw-r--r-- | Tests/ufoLib/GLIF2_test.py | 1370 |
1 files changed, 690 insertions, 680 deletions
diff --git a/Tests/ufoLib/GLIF2_test.py b/Tests/ufoLib/GLIF2_test.py index ab9495db..d8c96d65 100644 --- a/Tests/ufoLib/GLIF2_test.py +++ b/Tests/ufoLib/GLIF2_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 TestGLIF2(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=2, 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 TestGLIF2(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=2, + 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="2"> <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="2"> <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="2"> <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="2"> <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_illegal_wrong_number(self): - # wrong number - glif = """ + def testFormat_illegal_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_illegal_not_int(self): - # not an int - glif = """ + def testFormat_illegal_not_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="2"> <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="2"> Hello World. </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testAdvance_legal_widht_and_height(self): - # legal: width and height - glif = """ + def testAdvance_legal_widht_and_height(self): + # legal: width and height + glif = """ <glyph name="a" format="2"> <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="2"> <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="2"> <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="2"> <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="2"> <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="2"> <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="2"> <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="2"> <unicode hex="0062"/> <unicode hex="0063"/> @@ -265,33 +275,33 @@ class TestGLIF2(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="2"> <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="2"> <note> hëllö @@ -300,17 +310,17 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.note = "hëllö" """ - 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(self): - glif = """ + def testLib(self): + glif = """ <glyph name="a" format="2"> <outline> </outline> @@ -338,18 +348,18 @@ class TestGLIF2(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 testGuidelines_legal(self): - # legal - glif = """ + def testGuidelines_legal(self): + # legal + glif = """ <glyph name="a" format="2"> <guideline x="1"/> <guideline y="1"/> @@ -362,143 +372,143 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"x" : 1}, {"y" : 1}, {"angle" : 0, "x" : 1, "y" : 1}, {"angle" : 360, "x" : 1, "y" : 1}, {"angle" : 45.5, "x" : 1.1, "y" : 1.1}, {"name" : "a", "x" : 1}, {"color" : "1,1,1,1", "x" : 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 testGuidelines_illegal_x(self): - # x not an int or float - glif = """ + def testGuidelines_illegal_x(self): + # x not an int or float + glif = """ <glyph name="a" format="2"> <guideline x="a" y="1" angle="45"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : 45, "x" : "a", "y" : 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 testGuidelines_illegal_y(self): - # y not an int or float - glif = """ + def testGuidelines_illegal_y(self): + # y not an int or float + glif = """ <glyph name="a" format="2"> <guideline x="1" y="y" angle="45"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : 45, "x" : 1, "y" : "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 testGuidelines_illegal_angle(self): - # angle not an int or float - glif = """ + def testGuidelines_illegal_angle(self): + # angle not an int or float + glif = """ <glyph name="a" format="2"> <guideline x="1" y="1" angle="a"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : "a", "x" : 1, "y" : 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 testGuidelines_illegal_x_missing(self): - # x missing - glif = """ + def testGuidelines_illegal_x_missing(self): + # x missing + glif = """ <glyph name="a" format="2"> <guideline y="1" angle="45"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : 45, "y" : 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 testGuidelines_illegal_y_missing(self): - # y missing - glif = """ + def testGuidelines_illegal_y_missing(self): + # y missing + glif = """ <glyph name="a" format="2"> <guideline x="1" angle="45"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : 45, "x" : 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 testGuidelines_illegal_angle_missing(self): - # angle missing - glif = """ + def testGuidelines_illegal_angle_missing(self): + # angle missing + glif = """ <glyph name="a" format="2"> <guideline x="1" y="1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"x" : 1, "y" : 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 testGuidelines_illegal_angle_out_of_range(self): - # angle out of range - glif = """ + def testGuidelines_illegal_angle_out_of_range(self): + # angle out of range + glif = """ <glyph name="a" format="2"> <guideline x="1" y="1" angle="-1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : -1, "x" : "1", "y" : 1}] """ - 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="2"> <guideline x="1" y="1" angle="361"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"angle" : 361, "x" : "1", "y" : 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 testAnchors_legal(self): - # legal - glif = """ + def testAnchors_legal(self): + # legal + glif = """ <glyph name="a" format="2"> <anchor x="1" y="2" name="test" color="1,0,0,1"/> <anchor x="1" y="2"/> @@ -506,363 +516,363 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"color" : "1,0,0,1", "name" : "test", "x" : 1, "y" : 2}, {"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 testAnchors_illegal_x(self): - # x not an int or float - glif = """ + def testAnchors_illegal_x(self): + # x not an int or float + glif = """ <glyph name="a" format="2"> <anchor x="a" y="1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"x" : "a", "y" : 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 testAnchors_illegal_y(self): - # y not an int or float - glif = """ + def testAnchors_illegal_y(self): + # y not an int or float + glif = """ <glyph name="a" format="2"> <anchor x="1" y="a"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"x" : 1, "y" : "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 testAnchors_illegal_x_missing(self): - # x missing - glif = """ + def testAnchors_illegal_x_missing(self): + # x missing + glif = """ <glyph name="a" format="2"> <anchor y="1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"y" : 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 testAnchors_illegal_y_missing(self): - # y missing - glif = """ + def testAnchors_illegal_y_missing(self): + # y missing + glif = """ <glyph name="a" format="2"> <anchor x="1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.anchors = [{"x" : 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 testImage_legal(self): - # legal - glif = """ + def testImage_legal(self): + # legal + glif = """ <glyph name="a" format="2"> <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4" color="1,1,1,1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"color" : "1,1,1,1", "fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} """ - 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 testImage_legal_no_color_or_transformation(self): - # legal: no color or transformation - glif = """ + def testImage_legal_no_color_or_transformation(self): + # legal: no color or transformation + glif = """ <glyph name="a" format="2"> <image fileName="test.png"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 0, "xScale" : 1, "xyScale" : 0, "yOffset" : 0, "yScale" : 1, "yxScale" : 0} """ - 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 testImage_illegal_no_file_name(self): - # no file name - glif = """ + def testImage_illegal_no_file_name(self): + # no file name + glif = """ <glyph name="a" format="2"> <image xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4" color="1,1,1,1"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"color" : "1,1,1,1", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} """ - 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 testImage_bogus_transformation(self): - # bogus transformation - glif = """ + def testImage_bogus_transformation(self): + # bogus transformation + glif = """ <glyph name="a" format="2"> <image fileName="test.png" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : "a", "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} """ - 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="2"> <image fileName="test.png" xScale="2" xyScale="a" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : "a", "yOffset" : 4, "yScale" : 5, "yxScale" : 6} """ - 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="2"> <image fileName="test.png" xScale="2" xyScale="3" yxScale="a" yScale="5" xOffset="1" yOffset="4"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : "a"} """ - 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="2"> <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="a" xOffset="1" yOffset="4"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : "a", "yxScale" : 6} """ - 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="2"> <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="a" yOffset="4"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : "a", "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} """ - 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="2"> <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="a"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : "a", "yScale" : 5, "yxScale" : 6} """ - 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 testImage_bogus_color(self): - # bogus color - glif = """ + def testImage_bogus_color(self): + # bogus color + glif = """ <glyph name="a" format="2"> <image fileName="test.png" color="1,1,1,x"/> <outline> </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.image = {"color" : "1,1,1,x"} """ - 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 testOutline_unknown_element(self): - # unknown element - glif = """ + def testOutline_unknown_element(self): + # unknown element + glif = """ <glyph name="a" format="2"> <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="2"> <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="2"> <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="2"> <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_illegal_bogus_transformation(self): - # bogus values in transformation - glif = """ + def testComponent_illegal_bogus_transformation(self): + # bogus values in transformation + glif = """ <glyph name="a" format="2"> <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="2"> <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="2"> <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="2"> <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="2"> <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="2"> <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="2"> <outline> <contour> @@ -870,19 +880,19 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -895,7 +905,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) @@ -905,14 +915,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -921,10 +931,10 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.glifToPy, glif) - def testContourIdentifier(self): - glif = """ + def testContourIdentifier(self): + glif = """ <glyph name="a" format="2"> <outline> <contour identifier="foo"> @@ -932,19 +942,19 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath(**{"identifier" : "foo"}) 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_int(self): - # legal: int - glif = """ + def testPointCoordinates_legal_int(self): + # legal: int + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -953,20 +963,20 @@ class TestGLIF2(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 testPointCoordinates_legal_float(self): - # legal: float - glif = """ + def testPointCoordinates_legal_float(self): + # legal: float + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -975,20 +985,20 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1.1, -2.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 testPointCoordinates_illegal_x(self): - # illegal: x as string - glif = """ + def testPointCoordinates_illegal_x(self): + # illegal: x as string + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -997,18 +1007,18 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[("a", 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 testPointCoordinates_illegal_y(self): - # illegal: y as string - glif = """ + def testPointCoordinates_illegal_y(self): + # illegal: y as string + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -1017,18 +1027,18 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, "a")], **{"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 testPointTypeMove_legal(self): - # legal - glif = """ + def testPointTypeMove_legal(self): + # legal + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -1038,21 +1048,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1062,21 +1072,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1086,19 +1096,19 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1108,21 +1118,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1132,21 +1142,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1156,21 +1166,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1182,7 +1192,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1191,14 +1201,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1209,7 +1219,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) @@ -1217,14 +1227,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1236,7 +1246,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1245,14 +1255,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1262,21 +1272,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1287,7 +1297,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1295,14 +1305,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1315,7 +1325,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1325,12 +1335,12 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1342,7 +1352,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1351,14 +1361,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1369,7 +1379,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) @@ -1377,14 +1387,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1396,7 +1406,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1405,14 +1415,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1422,21 +1432,21 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1447,7 +1457,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1455,14 +1465,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1475,7 +1485,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1485,14 +1495,14 @@ class TestGLIF2(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_legal_no_on_curve(self): - # contour with no on curve - glif = """ + def testSpecialCaseQCurve_legal_no_on_curve(self): + # contour with no on curve + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -1504,7 +1514,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"smooth" : False}) @@ -1513,14 +1523,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1532,7 +1542,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) @@ -1541,14 +1551,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1559,7 +1569,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) @@ -1567,14 +1577,14 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1584,19 +1594,19 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1606,19 +1616,19 @@ class TestGLIF2(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="2"> <outline> <contour> @@ -1628,18 +1638,18 @@ class TestGLIF2(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 testOpenContourLooseOffCurves(self): - glif = """ + def testOpenContourLooseOffCurves(self): + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -1652,8 +1662,8 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - self.assertRaises(GlifLibError, self.glifToPy, glif) - py = """ + self.assertRaises(GlifLibError, self.glifToPy, glif) + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) @@ -1663,10 +1673,10 @@ class TestGLIF2(unittest.TestCase): pointPen.addPoint(*[(1, 2)], **{"smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.pyToGLIF, py) - def testPointIdentifier(self): - glif = """ + def testPointIdentifier(self): + glif = """ <glyph name="a" format="2"> <outline> <contour> @@ -1678,7 +1688,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" pointPen.beginPath() pointPen.addPoint(*[(1, -2)], **{"identifier" : "1", "segmentType" : "move", "smooth" : False}) @@ -1687,13 +1697,13 @@ class TestGLIF2(unittest.TestCase): pointPen.addPoint(*[(1, -2)], **{"identifier" : "4", "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 testIdentifierConflict_legal_no_conflict(self): - glif = """ + def testIdentifierConflict_legal_no_conflict(self): + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1714,7 +1724,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1730,14 +1740,14 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_point_point(self): - # point - point - glif = """ + def testIdentifierConflict_point_point(self): + # point - point + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1758,7 +1768,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1774,12 +1784,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_point_contour(self): - # point - contour - glif = """ + def testIdentifierConflict_point_contour(self): + # point - contour + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1800,7 +1810,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1816,12 +1826,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_point_component(self): - # point - component - glif = """ + def testIdentifierConflict_point_component(self): + # point - component + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1842,7 +1852,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1858,12 +1868,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_point_guideline(self): - # point - guideline - glif = """ + def testIdentifierConflict_point_guideline(self): + # point - guideline + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1884,7 +1894,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1900,12 +1910,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_point_anchor(self): - # point - anchor - glif = """ + def testIdentifierConflict_point_anchor(self): + # point - anchor + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1926,7 +1936,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1942,12 +1952,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_contour_contour(self): - # contour - contour - glif = """ + def testIdentifierConflict_contour_contour(self): + # contour - contour + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -1968,7 +1978,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -1984,12 +1994,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_contour_component(self): - # contour - component - glif = """ + def testIdentifierConflict_contour_component(self): + # contour - component + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -2010,7 +2020,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2026,12 +2036,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "contour1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_contour_guideline(self): - # contour - guideline - glif = """ + def testIdentifierConflict_contour_guideline(self): + # contour - guideline + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="contour1"/> <guideline x="0" identifier="guideline2"/> @@ -2052,7 +2062,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "contour1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2068,12 +2078,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_contour_anchor(self): - # contour - anchor - glif = """ + def testIdentifierConflict_contour_anchor(self): + # contour - anchor + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -2094,7 +2104,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2110,12 +2120,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_component_component(self): - # component - component - glif = """ + def testIdentifierConflict_component_component(self): + # component - component + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -2136,7 +2146,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2152,12 +2162,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) """ - 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 testIdentifierConflict_component_guideline(self): - # component - guideline - glif = """ + def testIdentifierConflict_component_guideline(self): + # component - guideline + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="component1"/> <guideline x="0" identifier="guideline2"/> @@ -2178,7 +2188,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "component1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2194,12 +2204,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_component_anchor(self): - # component - anchor - glif = """ + def testIdentifierConflict_component_anchor(self): + # component - anchor + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -2220,7 +2230,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2236,12 +2246,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "anchor1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_guideline_guideline(self): - # guideline - guideline - glif = """ + def testIdentifierConflict_guideline_guideline(self): + # guideline - guideline + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline1"/> @@ -2262,7 +2272,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline1", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2278,12 +2288,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_guideline_anchor(self): - # guideline - anchor - glif = """ + def testIdentifierConflict_guideline_anchor(self): + # guideline - anchor + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="anchor1"/> <guideline x="0" identifier="guideline2"/> @@ -2304,7 +2314,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "anchor1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] @@ -2320,12 +2330,12 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - 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 testIdentifierConflict_anchor_anchor(self): - # anchor - anchor - glif = """ + def testIdentifierConflict_anchor_anchor(self): + # anchor - anchor + glif = """ <glyph name="a" format="2"> <guideline x="0" identifier="guideline1"/> <guideline x="0" identifier="guideline2"/> @@ -2346,7 +2356,7 @@ class TestGLIF2(unittest.TestCase): </outline> </glyph> """ - py = """ + py = """ glyph.name = "a" glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor1", "x" : 0, "y" : 0}] @@ -2362,5 +2372,5 @@ class TestGLIF2(unittest.TestCase): pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + self.assertRaises(GlifLibError, self.pyToGLIF, py) + self.assertRaises(GlifLibError, self.glifToPy, glif) |