11import csv
22import json
3+ import plistlib
34import random
45from functools import partial , wraps
56from 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}
6063Expected format:
61- { str_representation !s }
64+ { representation . decode ( "utf-8" ) }
6265Actual 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