From ca6126ea67b855568c6fd03d5c07fc9d4ee1525a Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Wed, 10 Jun 2015 10:09:28 +0200 Subject: [PATCH] =?UTF-8?q?[GX]=20Fix=20=E2=80=98gvar=E2=80=99=20unittest?= =?UTF-8?q?=20on=20Python=202.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unittest.TestCase.assertSetEqual() was added in Python 2.7, so we default to assertEqual() on Python 2.6. --- Lib/fontTools/ttLib/tables/_g_v_a_r_test.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/_g_v_a_r_test.py b/Lib/fontTools/ttLib/tables/_g_v_a_r_test.py index 87a5882e9..a3a64957e 100644 --- a/Lib/fontTools/ttLib/tables/_g_v_a_r_test.py +++ b/Lib/fontTools/ttLib/tables/_g_v_a_r_test.py @@ -159,6 +159,11 @@ class GlyphVariationTableTest(unittest.TestCase): self.assertEqual({"wght": 0.0, "wdth": 0.7}, maxCoord) class GlyphVariationTest(unittest.TestCase): + def __init__(self, methodName): + unittest.TestCase.__init__(self, methodName) + if not hasattr(self, "assertSetEqual"): # only in Python 2.7 and later + self.assertSetEqual = self.assertEqual + def test_equal(self): gvar1 = GlyphVariation({"wght":(0.0, 1.0, 1.0)}, [(0,0), (9,8), (7,6)]) gvar2 = GlyphVariation({"wght":(0.0, 1.0, 1.0)}, [(0,0), (9,8), (7,6)]) @@ -443,16 +448,12 @@ class GlyphVariationTest(unittest.TestCase): numPointsInGlyph = 500 # greater than 255, so we also exercise code path for 16-bit encoding compile = GlyphVariation.compilePoints decompile = lambda data: set(GlyphVariation.decompilePoints_(numPointsInGlyph, data, 0)[0]) - if hasattr(self, "assertSetEqual"): # only in Python 2.7 and later - assertSetEqual = self.assertSetEqual - else: - assertSetEqual = self.assertEqual for i in range(50): points = set(random.sample(range(numPointsInGlyph), 30)) - assertSetEqual(points, decompile(compile(points)), - "failed round-trip decompile/compilePoints; points=%s" % points) + self.assertSetEqual(points, decompile(compile(points)), + "failed round-trip decompile/compilePoints; points=%s" % points) allPoints = set(range(numPointsInGlyph)) - assertSetEqual(allPoints, decompile(compile(allPoints))) + self.assertSetEqual(allPoints, decompile(compile(allPoints))) def test_compileDeltas(self): gvar = GlyphVariation({}, [(0,0), (1, 0), (2, 0), (3, 3)])