Upgrade Tests/ufoLib to Python 3.6+ syntax

This commit is contained in:
Nikolaus Waxweiler 2019-09-09 21:39:22 +01:00 committed by Nikolaus Waxweiler
parent 66dec63231
commit 14bb52a616
9 changed files with 16 additions and 23 deletions

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest
from fontTools.ufoLib.glifLib import GlifLibError, readGlyphFromString, writeGlyphToString
from .testSupport import Glyph, stripText
@ -19,7 +18,7 @@ class TestGLIF1(unittest.TestCase):
first = stripText(first)
if isinstance(second, basestring):
second = stripText(second)
return super(TestGLIF1, self).assertEqual(first, second, msg=msg)
return super().assertEqual(first, second, msg=msg)
def pyToGLIF(self, py):
py = stripText(py)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import unittest
from fontTools.ufoLib.glifLib import GlifLibError, readGlyphFromString, writeGlyphToString
from .testSupport import Glyph, stripText
@ -19,7 +18,7 @@ class TestGLIF2(unittest.TestCase):
first = stripText(first)
if isinstance(second, basestring):
second = stripText(second)
return super(TestGLIF2, self).assertEqual(first, second, msg=msg)
return super().assertEqual(first, second, msg=msg)
def pyToGLIF(self, py):
py = stripText(py)

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import shutil
import unittest
@ -9,7 +8,7 @@ from fontTools.ufoLib import plistlib
from .testSupport import fontInfoVersion1, fontInfoVersion2
class TestInfoObject(object): pass
class TestInfoObject: pass
class ReadFontInfoVersion1TestCase(unittest.TestCase):

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import shutil
import unittest
@ -9,7 +8,7 @@ from fontTools.ufoLib import plistlib
from .testSupport import fontInfoVersion2
class TestInfoObject(object): pass
class TestInfoObject: pass
class ReadFontInfoVersion2TestCase(unittest.TestCase):

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import shutil
import unittest
@ -11,7 +10,7 @@ from fontTools.misc import plistlib
from .testSupport import fontInfoVersion3
class TestInfoObject(object): pass
class TestInfoObject: pass
# --------------
@ -4310,7 +4309,7 @@ class UFO3WriteDataTestCase(unittest.TestCase):
# layerinfo.plist
# ---------------
class TestLayerInfoObject(object):
class TestLayerInfoObject:
color = guidelines = lib = None

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
import shutil
import unittest
@ -121,7 +120,7 @@ class ConversionFunctionsTestCase(unittest.TestCase):
# kerning up conversion
# ---------------------
class TestInfoObject(object): pass
class TestInfoObject: pass
class KerningUpConversionTestCase(unittest.TestCase):

View File

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from fontTools.misc.py23 import tostr
from fontTools.ufoLib import UFOReader, UFOWriter, UFOFileStructure
from fontTools.ufoLib.errors import UFOLibError, GlifLibError
@ -38,7 +37,7 @@ def testufoz():
yield tmp.getsyspath(TEST_UFOZ)
class TestUFOZ(object):
class TestUFOZ:
def test_read(self, testufoz):
with UFOReader(testufoz) as reader:
@ -54,7 +53,7 @@ class TestUFOZ(object):
def test_pathlike(testufo):
class PathLike(object):
class PathLike:
def __init__(self, s):
self._path = s
@ -84,7 +83,7 @@ def memufo():
return m
class TestMemoryFS(object):
class TestMemoryFS:
def test_init_reader(self, memufo):
with UFOReader(memufo) as reader:

View File

@ -138,7 +138,7 @@ class FileNameTests(unittest.TestCase):
self.assertEqual(glyphNameToFileName("alt.con", None), "alt._con.glif")
class _Glyph(object):
class _Glyph:
pass

View File

@ -21,7 +21,7 @@ def getDemoFontGlyphSetPath():
# GLIF test tools
class Glyph(object):
class Glyph:
def __init__(self):
self.name = None
@ -39,11 +39,11 @@ class Glyph(object):
args = _listToString(args)
kwargs = _dictToString(kwargs)
if args and kwargs:
return "pointPen.%s(*%s, **%s)" % (command, args, kwargs)
return f"pointPen.{command}(*{args}, **{kwargs})"
elif len(args):
return "pointPen.%s(*%s)" % (command, args)
return f"pointPen.{command}(*{args})"
elif len(kwargs):
return "pointPen.%s(**%s)" % (command, kwargs)
return f"pointPen.{command}(**{kwargs})"
else:
return "pointPen.%s()" % command
@ -104,7 +104,7 @@ def _dictToString(d):
value = repr(value)
elif isinstance(value, basestring):
value = "\"%s\"" % value
text.append("%s : %s" % (key, value))
text.append(f"{key} : {value}")
if not text:
return ""
return "{%s}" % ", ".join(text)