2222# this package
2323from domdf_python_tools .pretty_print import FancyPrinter , simple_repr
2424from domdf_python_tools .stringlist import StringList
25-
2625# list, tuple and dict subclasses that do or don't overwrite __repr__
26+ from domdf_python_tools .testing import check_file_regression
2727
2828
2929class list2 (list ):
@@ -497,7 +497,7 @@ def test_ordered_dict(self, file_regression: FileRegressionFixture):
497497 assert FancyPrinter (width = 1 ).pformat (d ) == "OrderedDict()"
498498 words = "the quick brown fox jumped over a lazy dog" .split ()
499499 d = collections .OrderedDict (zip (words , itertools .count ()))
500- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
500+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
501501
502502 def test_mapping_proxy (self ):
503503 words = "the quick brown fox jumped over a lazy dog" .split ()
@@ -546,7 +546,7 @@ def test_small_simple_namespace(self):
546546
547547 def test_subclassing (self , file_regression : FileRegressionFixture ):
548548 o = {"names with spaces" : "should be presented using repr()" , "others.should.not.be" : "like.this" }
549- file_regression . check (DottedPrettyPrinter ().pformat (o ), extension = ".txt" , encoding = "UTF-8" )
549+ check_file_regression (DottedPrettyPrinter ().pformat (o ), file_regression )
550550
551551 @pytest .mark .parametrize (
552552 "value, width" ,
@@ -559,7 +559,7 @@ def test_subclassing(self, file_regression: FileRegressionFixture):
559559 def test_set_reprs (self , value , width , file_regression : FileRegressionFixture ):
560560 assert FancyPrinter ().pformat (set ()) == "set()"
561561 assert FancyPrinter ().pformat (set (range (3 ))) == "{0, 1, 2}"
562- self . check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
562+ check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
563563
564564 @pytest .mark .parametrize (
565565 "value, width" ,
@@ -572,7 +572,7 @@ def test_set_reprs(self, value, width, file_regression: FileRegressionFixture):
572572 def test_frozenset_reprs (self , value , width , file_regression : FileRegressionFixture ):
573573 assert FancyPrinter ().pformat (frozenset ()) == "frozenset()"
574574 assert FancyPrinter ().pformat (frozenset (range (3 ))) == "frozenset({0, 1, 2})"
575- self . check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
575+ check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
576576
577577 def test_depth (self ):
578578 nested_tuple = (1 , (2 , (3 , (4 , (5 , 6 )))))
@@ -853,34 +853,34 @@ def test_bytes_wrap(self):
853853 ]
854854 )
855855 def test_bytearray_wrap (self , value , width , file_regression : FileRegressionFixture ):
856- self . check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
856+ check_file_regression (FancyPrinter (width = width ).pformat (value ), file_regression )
857857
858858 def test_default_dict (self , file_regression : FileRegressionFixture ):
859859 d : collections .defaultdict = collections .defaultdict (int )
860860 assert FancyPrinter (width = 1 ).pformat (d ) == "defaultdict(<class 'int'>, {})"
861861 words = "the quick brown fox jumped over a lazy dog" .split ()
862862 d = collections .defaultdict (int , zip (words , itertools .count ()))
863- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
863+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
864864
865865 def test_counter (self , file_regression : FileRegressionFixture ):
866866 d : collections .Counter = collections .Counter ()
867867 assert FancyPrinter (width = 1 ).pformat (d ) == "Counter()"
868868 d = collections .Counter ("senselessness" )
869- self . check_file_regression (FancyPrinter (width = 40 ).pformat (d ), file_regression )
869+ check_file_regression (FancyPrinter (width = 40 ).pformat (d ), file_regression )
870870
871871 def test_chainmap (self , file_regression : FileRegressionFixture ):
872872 d : collections .ChainMap = collections .ChainMap ()
873873 assert FancyPrinter (width = 1 ).pformat (d ) == "ChainMap({})"
874874 words = "the quick brown fox jumped over a lazy dog" .split ()
875875 items = list (zip (words , itertools .count ()))
876876 d = collections .ChainMap (dict (items ))
877- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
877+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
878878
879879 def test_chainmap_nested (self , file_regression : FileRegressionFixture ):
880880 words = "the quick brown fox jumped over a lazy dog" .split ()
881881 items = list (zip (words , itertools .count ()))
882882 d = collections .ChainMap (dict (items ), collections .OrderedDict (items ))
883- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
883+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
884884
885885 def test_deque (self ):
886886 d : collections .deque = collections .deque ()
@@ -914,22 +914,19 @@ def test_deque(self):
914914 ('dog', 8)],
915915 maxlen=7)"""
916916
917- def check_file_regression (self , data , file_regression : FileRegressionFixture ):
918- file_regression .check (data , extension = ".txt" , encoding = "UTF-8" )
919-
920917 def test_user_dict (self , file_regression : FileRegressionFixture ):
921918 d : collections .UserDict = collections .UserDict ()
922919 assert FancyPrinter (width = 1 ).pformat (d ) == "{}"
923920 words = "the quick brown fox jumped over a lazy dog" .split ()
924921 d = collections .UserDict (zip (words , itertools .count ())) # type: ignore
925- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
922+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
926923
927924 def test_user_list (self , file_regression : FileRegressionFixture ):
928925 d : collections .UserList = collections .UserList ()
929926 assert FancyPrinter (width = 1 ).pformat (d ) == "[]"
930927 words = "the quick brown fox jumped over a lazy dog" .split ()
931928 d = collections .UserList (zip (words , itertools .count ()))
932- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
929+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
933930
934931 @pytest .mark .parametrize (
935932 "value, width, expects" ,
@@ -983,4 +980,4 @@ class F:
983980 c = "cherry"
984981 d = list (range (100 ))
985982
986- file_regression . check (repr (F ()), encoding = "UTF-8" , extension = ".txt" )
983+ check_file_regression (repr (F ()), file_regression )
0 commit comments