self.assertEqual(glyphNameToFileName("T_h", None), "T__h.glif") self.assertEqual(glyphNameToFileName("t_h", None), "t_h.glif") self.assertEqual(glyphNameToFileName('F_F_I', None), "F__F__I_.glif") self.assertEqual(glyphNameToFileName('f_f_i', None), "f_f_i.glif") def testShortFileNameScheme(self): self.assertEqual(glyphNameToShortFileName("a", None), "a.glif") self.assertEqual(glyphNameToShortFileName("A", None), "A_.glif") self.assertEqual(glyphNameToShortFileName("a.alt", None), "a_alt.glif") self.assertEqual(glyphNameToShortFileName("A.alt", None), "A__alt.glif") self.assertEqual(glyphNameToShortFileName("a.alt#swash", None), "a_alt_swash.glif") self.assertEqual(glyphNameToShortFileName("A.alt", None), "A__alt.glif") self.assertEqual(glyphNameToShortFileName(".notdef", None), "_notdef.glif") self.assertEqual(glyphNameToShortFileName("f_f_i", None), "f_f_i.glif") self.assertEqual(glyphNameToShortFileName("F_F_I", None), "F__F__I_.glif") self.assertEqual(glyphNameToShortFileName("acircumflexdieresis.swash.alt1", None), "acircumflexdieresi0cfc8352.glif") self.assertEqual(glyphNameToShortFileName("acircumflexdieresis.swash.alt2", None), "acircumflexdieresi95f5d2e8.glif") self.assertEqual(glyphNameToShortFileName("Acircumflexdieresis.swash.alt1", None), "A_circumflexdieresed24fb56.glif") self.assertEqual(glyphNameToShortFileName("F#weight0.800_width0.425", None), "F__weight0_800_width0_425.glif") self.assertEqual(glyphNameToShortFileName("F#weight0.83245511_width0.425693567", None), "F__weight0_8324551c9a4143c.glif") self.assertEqual(len(glyphNameToShortFileName("F#weight0.83245511_width0.425693567", None)), 31) if __name__ == "__main__": from robofab.test.testSupport import runTests import sys if len(sys.argv) > 1 and os.path.isdir(sys.argv[-1]): GLYPHSETDIR = sys.argv.pop() runTests()
def testVersion1DeprecationRoundTrip(self): """ unittest doesn't catch warnings in self.assertRaises, so some hackery is required to catch the warnings that are raised when setting deprecated attributes. """ saveStderr = sys.stderr tempStderr = StringIO() sys.stderr = tempStderr infoObject = RInfo() requiredWarnings = [] try: for attr, value in fontInfoVersion1.items(): if attr in ufoLib.deprecatedFontInfoAttributesVersion2: setattr(infoObject, attr, value) v = getattr(infoObject, attr) self.assertEquals((attr, value), (attr, v)) s = "DeprecationWarning: The %s attribute has been deprecated." % attr requiredWarnings.append((attr, s)) finally: sys.stderr = saveStderr tempStderr = tempStderr.getvalue() for attr, line in requiredWarnings: self.assertEquals((attr, line in tempStderr), (attr, True)) if __name__ == "__main__": from robofab.test.testSupport import runTests runTests()