aboutsummaryrefslogtreecommitdiff
path: root/Tests/ttLib/tables/_m_e_t_a_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/ttLib/tables/_m_e_t_a_test.py')
-rw-r--r--Tests/ttLib/tables/_m_e_t_a_test.py64
1 files changed, 34 insertions, 30 deletions
diff --git a/Tests/ttLib/tables/_m_e_t_a_test.py b/Tests/ttLib/tables/_m_e_t_a_test.py
index f05ff576..e96c492c 100644
--- a/Tests/ttLib/tables/_m_e_t_a_test.py
+++ b/Tests/ttLib/tables/_m_e_t_a_test.py
@@ -11,7 +11,8 @@ import unittest
# and shortened the payload.
META_DATA = deHexStr(
"00 00 00 01 00 00 00 00 00 00 00 1C 00 00 00 01 "
- "54 45 53 54 00 00 00 1C 00 00 00 04 CA FE BE EF")
+ "54 45 53 54 00 00 00 1C 00 00 00 04 CA FE BE EF"
+)
# The 'dlng' and 'slng' tag with text data containing "augmented" BCP 47
# comma-separated or comma-space-separated tags. These should be UTF-8 encoded
@@ -21,7 +22,9 @@ META_DATA_TEXT = deHexStr(
"64 6C 6E 67 00 00 00 28 00 00 00 0E 73 6C 6E 67 "
"00 00 00 36 00 00 00 0E 4C 61 74 6E 2C 47 72 65 "
"6B 2C 43 79 72 6C 4C 61 74 6E 2C 47 72 65 6B 2C "
- "43 79 72 6C")
+ "43 79 72 6C"
+)
+
class MetaTableTest(unittest.TestCase):
def test_decompile(self):
@@ -37,13 +40,14 @@ class MetaTableTest(unittest.TestCase):
def test_decompile_text(self):
table = table__m_e_t_a()
table.decompile(META_DATA_TEXT, ttFont={"meta": table})
- self.assertEqual({"dlng": u"Latn,Grek,Cyrl",
- "slng": u"Latn,Grek,Cyrl"}, table.data)
+ self.assertEqual(
+ {"dlng": "Latn,Grek,Cyrl", "slng": "Latn,Grek,Cyrl"}, table.data
+ )
def test_compile_text(self):
table = table__m_e_t_a()
- table.data["dlng"] = u"Latn,Grek,Cyrl"
- table.data["slng"] = u"Latn,Grek,Cyrl"
+ table.data["dlng"] = "Latn,Grek,Cyrl"
+ table.data["slng"] = "Latn,Grek,Cyrl"
self.assertEqual(META_DATA_TEXT, table.compile(ttFont={"meta": table}))
def test_toXML(self):
@@ -52,11 +56,10 @@ class MetaTableTest(unittest.TestCase):
writer = XMLWriter(BytesIO())
table.toXML(writer, {"meta": table})
xml = writer.file.getvalue().decode("utf-8")
- self.assertEqual([
- '<hexdata tag="TEST">',
- 'cafebeef',
- '</hexdata>'
- ], [line.strip() for line in xml.splitlines()][1:])
+ self.assertEqual(
+ ['<hexdata tag="TEST">', "cafebeef", "</hexdata>"],
+ [line.strip() for line in xml.splitlines()][1:],
+ )
def test_toXML_ascii_data(self):
table = table__m_e_t_a()
@@ -64,44 +67,45 @@ class MetaTableTest(unittest.TestCase):
writer = XMLWriter(BytesIO())
table.toXML(writer, {"meta": table})
xml = writer.file.getvalue().decode("utf-8")
- self.assertEqual([
- '<hexdata tag="TEST">',
- '<!-- ascii: Hello! -->',
- '48656c6c 6f21',
- '</hexdata>'
- ], [line.strip() for line in xml.splitlines()][1:])
+ self.assertEqual(
+ [
+ '<hexdata tag="TEST">',
+ "<!-- ascii: Hello! -->",
+ "48656c6c 6f21",
+ "</hexdata>",
+ ],
+ [line.strip() for line in xml.splitlines()][1:],
+ )
def test_fromXML(self):
table = table__m_e_t_a()
for name, attrs, content in parseXML(
- '<hexdata tag="TEST">'
- ' cafebeef'
- '</hexdata>'):
+ '<hexdata tag="TEST">' " cafebeef" "</hexdata>"
+ ):
table.fromXML(name, attrs, content, ttFont=None)
self.assertEqual({"TEST": b"\xCA\xFE\xBE\xEF"}, table.data)
def test_toXML_text(self):
table = table__m_e_t_a()
- table.data["dlng"] = u"Latn,Grek,Cyrl"
+ table.data["dlng"] = "Latn,Grek,Cyrl"
writer = XMLWriter(BytesIO())
table.toXML(writer, {"meta": table})
xml = writer.file.getvalue().decode("utf-8")
- self.assertEqual([
- '<text tag="dlng">',
- 'Latn,Grek,Cyrl',
- '</text>'
- ], [line.strip() for line in xml.splitlines()][1:])
+ self.assertEqual(
+ ['<text tag="dlng">', "Latn,Grek,Cyrl", "</text>"],
+ [line.strip() for line in xml.splitlines()][1:],
+ )
def test_fromXML_text(self):
table = table__m_e_t_a()
for name, attrs, content in parseXML(
- '<text tag="dlng">'
- ' Latn,Grek,Cyrl'
- '</text>'):
+ '<text tag="dlng">' " Latn,Grek,Cyrl" "</text>"
+ ):
table.fromXML(name, attrs, content, ttFont=None)
- self.assertEqual({"dlng": u"Latn,Grek,Cyrl"}, table.data)
+ self.assertEqual({"dlng": "Latn,Grek,Cyrl"}, table.data)
if __name__ == "__main__":
import sys
+
sys.exit(unittest.main())