Skip to content

Commit e92b5e4

Browse files
committed
Add formatting unit test for plist
1 parent 5388f8f commit e92b5e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/test_formatting.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import csv
22
import json
3+
import plistlib
34
import random
45
from functools import partial, wraps
56
from io import StringIO
@@ -44,8 +45,10 @@ def wrapper(self: 'TestFormatting'):
4445
formatter = filetype.get_default_formatter()
4546

4647
for _ in trange(iterations):
47-
orig_obj, str_representation = test_func(self)
48-
with graphtage.utils.Tempfile(str_representation.encode('utf-8')) as t:
48+
orig_obj, representation = test_func(self)
49+
if isinstance(representation, str):
50+
representation = representation.encode("utf-8")
51+
with graphtage.utils.Tempfile(representation) as t:
4952
tree = filetype.build_tree(t)
5053
stream = StringIO()
5154
printer = graphtage.printer.Printer(out_stream=stream, ansi_color=False)
@@ -58,7 +61,7 @@ def wrapper(self: 'TestFormatting'):
5861
self.fail(f"""{filetype_name.upper()} decode error {e}: Original object:
5962
{orig_obj!r}
6063
Expected format:
61-
{str_representation!s}
64+
{representation.decode("utf-8")}
6265
Actual format:
6366
{formatted_str!s}""")
6467
if test_equality:
@@ -245,3 +248,8 @@ def test_yaml_formatting(self):
245248
s = StringIO()
246249
yaml.dump(orig_obj, s, Dumper=graphtage.yaml.Dumper)
247250
return orig_obj, s.getvalue()
251+
252+
@filetype_test(test_equality=False)
253+
def test_plist_formatting(self):
254+
orig_obj = TestFormatting.make_random_obj(force_string_keys=True, exclude_bytes=frozenset('<>/\n&?|@{}[]'))
255+
return orig_obj, plistlib.dumps(orig_obj)

0 commit comments

Comments
 (0)