22
22
# this package
23
23
from domdf_python_tools .pretty_print import FancyPrinter , simple_repr
24
24
from domdf_python_tools .stringlist import StringList
25
-
26
25
# list, tuple and dict subclasses that do or don't overwrite __repr__
26
+ from domdf_python_tools .testing import check_file_regression
27
27
28
28
29
29
class list2 (list ):
@@ -497,7 +497,7 @@ def test_ordered_dict(self, file_regression: FileRegressionFixture):
497
497
assert FancyPrinter (width = 1 ).pformat (d ) == "OrderedDict()"
498
498
words = "the quick brown fox jumped over a lazy dog" .split ()
499
499
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 )
501
501
502
502
def test_mapping_proxy (self ):
503
503
words = "the quick brown fox jumped over a lazy dog" .split ()
@@ -546,7 +546,7 @@ def test_small_simple_namespace(self):
546
546
547
547
def test_subclassing (self , file_regression : FileRegressionFixture ):
548
548
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 )
550
550
551
551
@pytest .mark .parametrize (
552
552
"value, width" ,
@@ -559,7 +559,7 @@ def test_subclassing(self, file_regression: FileRegressionFixture):
559
559
def test_set_reprs (self , value , width , file_regression : FileRegressionFixture ):
560
560
assert FancyPrinter ().pformat (set ()) == "set()"
561
561
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 )
563
563
564
564
@pytest .mark .parametrize (
565
565
"value, width" ,
@@ -572,7 +572,7 @@ def test_set_reprs(self, value, width, file_regression: FileRegressionFixture):
572
572
def test_frozenset_reprs (self , value , width , file_regression : FileRegressionFixture ):
573
573
assert FancyPrinter ().pformat (frozenset ()) == "frozenset()"
574
574
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 )
576
576
577
577
def test_depth (self ):
578
578
nested_tuple = (1 , (2 , (3 , (4 , (5 , 6 )))))
@@ -853,34 +853,34 @@ def test_bytes_wrap(self):
853
853
]
854
854
)
855
855
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 )
857
857
858
858
def test_default_dict (self , file_regression : FileRegressionFixture ):
859
859
d : collections .defaultdict = collections .defaultdict (int )
860
860
assert FancyPrinter (width = 1 ).pformat (d ) == "defaultdict(<class 'int'>, {})"
861
861
words = "the quick brown fox jumped over a lazy dog" .split ()
862
862
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 )
864
864
865
865
def test_counter (self , file_regression : FileRegressionFixture ):
866
866
d : collections .Counter = collections .Counter ()
867
867
assert FancyPrinter (width = 1 ).pformat (d ) == "Counter()"
868
868
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 )
870
870
871
871
def test_chainmap (self , file_regression : FileRegressionFixture ):
872
872
d : collections .ChainMap = collections .ChainMap ()
873
873
assert FancyPrinter (width = 1 ).pformat (d ) == "ChainMap({})"
874
874
words = "the quick brown fox jumped over a lazy dog" .split ()
875
875
items = list (zip (words , itertools .count ()))
876
876
d = collections .ChainMap (dict (items ))
877
- self . check_file_regression (FancyPrinter ().pformat (d ), file_regression )
877
+ check_file_regression (FancyPrinter ().pformat (d ), file_regression )
878
878
879
879
def test_chainmap_nested (self , file_regression : FileRegressionFixture ):
880
880
words = "the quick brown fox jumped over a lazy dog" .split ()
881
881
items = list (zip (words , itertools .count ()))
882
882
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 )
884
884
885
885
def test_deque (self ):
886
886
d : collections .deque = collections .deque ()
@@ -914,22 +914,19 @@ def test_deque(self):
914
914
('dog', 8)],
915
915
maxlen=7)"""
916
916
917
- def check_file_regression (self , data , file_regression : FileRegressionFixture ):
918
- file_regression .check (data , extension = ".txt" , encoding = "UTF-8" )
919
-
920
917
def test_user_dict (self , file_regression : FileRegressionFixture ):
921
918
d : collections .UserDict = collections .UserDict ()
922
919
assert FancyPrinter (width = 1 ).pformat (d ) == "{}"
923
920
words = "the quick brown fox jumped over a lazy dog" .split ()
924
921
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 )
926
923
927
924
def test_user_list (self , file_regression : FileRegressionFixture ):
928
925
d : collections .UserList = collections .UserList ()
929
926
assert FancyPrinter (width = 1 ).pformat (d ) == "[]"
930
927
words = "the quick brown fox jumped over a lazy dog" .split ()
931
928
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 )
933
930
934
931
@pytest .mark .parametrize (
935
932
"value, width, expects" ,
@@ -983,4 +980,4 @@ class F:
983
980
c = "cherry"
984
981
d = list (range (100 ))
985
982
986
- file_regression . check (repr (F ()), encoding = "UTF-8" , extension = ".txt" )
983
+ check_file_regression (repr (F ()), file_regression )
0 commit comments