@@ -34,7 +34,7 @@ class TestValidationResultSet:
3434
3535 def test_defaults (self ):
3636 """Check defaults."""
37- df = result .ValidationResultSet (index = ["a" , "b" ])
37+ df = result .ValidationResultSet (index = ["a" , "b" ], auto_format = True )
3838 assert df .to_dict () == {
3939 "is_valid" : {"a" : True , "b" : True },
4040 "ret_code" : {"a" : 0 , "b" : 0 },
@@ -44,7 +44,7 @@ def test_defaults(self):
4444
4545 def test_defaults_with_extra_data (self ):
4646 """Check defaults with extra data."""
47- df = result .ValidationResultSet ({"a" : [1 , 2 ], "b" : [3 , 4 ]})
47+ df = result .ValidationResultSet ({"a" : [1 , 2 ], "b" : [3 , 4 ]}, auto_format = True )
4848 assert df .to_dict () == {
4949 "is_valid" : {0 : True , 1 : True },
5050 "ret_code" : {0 : 0 , 1 : 0 },
@@ -56,7 +56,7 @@ def test_defaults_with_extra_data(self):
5656
5757 def test_default_ret_code (self ):
5858 """Check default return code."""
59- df = result .ValidationResultSet ({"is_valid" : [True , False , True , False ]})
59+ df = result .ValidationResultSet ({"is_valid" : [True , False , True , False ]}, auto_format = True )
6060 assert df .to_dict () == {
6161 "is_valid" : {0 : True , 1 : False , 2 : True , 3 : False },
6262 "ret_code" : {0 : 0 , 1 : 1 , 2 : 0 , 3 : 1 },
@@ -67,7 +67,9 @@ def test_default_ret_code(self):
6767 def test_output_columns (self ):
6868 """Check output_columns argument."""
6969 df = result .ValidationResultSet (
70- index = ["a" , "b" ], output_columns = {"col1" : "val1" , "col2" : "val2" }
70+ index = ["a" , "b" ],
71+ output_columns = {"col1" : "val1" , "col2" : "val2" },
72+ auto_format = True ,
7173 )
7274 assert df .to_dict () == {
7375 "is_valid" : {"a" : True , "b" : True },
@@ -84,6 +86,7 @@ def test_output_columns_with_existing_columns(self):
8486 {"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
8587 index = ["a" , "b" ],
8688 output_columns = {"col1" : "val1" , "col2" : "val2" },
89+ auto_format = True ,
8790 )
8891 assert df .to_dict () == {
8992 "is_valid" : {"a" : True , "b" : False },
@@ -126,9 +129,11 @@ def test_column_order(self):
126129 {"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
127130 index = ["a" , "b" ],
128131 output_columns = {"col1" : "val1" , "col2" : "val2" },
132+ auto_format = True ,
129133 )
130134 df_order = result .ValidationResultSet (
131- pd .DataFrame (df [["col2" , "comment" , "is_valid" , "col1" , "exception" , "ret_code" ]])
135+ pd .DataFrame (df [["col2" , "comment" , "is_valid" , "col1" , "exception" , "ret_code" ]]),
136+ auto_format = True ,
132137 )
133138 assert df_order .columns .tolist () == [
134139 "is_valid" ,
@@ -153,7 +158,8 @@ def test_column_order(self):
153158 "ret_code" ,
154159 ]
155160 ]
156- )
161+ ),
162+ auto_format = True ,
157163 )
158164 assert df_order .columns .tolist () == [
159165 "is_valid" ,
@@ -171,6 +177,7 @@ def test_pandas_method(self):
171177 {"is_valid" : [True , False ], "col1" : ["test1" , "test2" ]},
172178 index = ["a" , "b" ],
173179 output_columns = {"col1" : "val1" , "col2" : "val2" },
180+ auto_format = True ,
174181 )
175182 new_df = result .ValidationResultSet (df )
176183 assert new_df .apply (lambda x : x .ret_code * 5 , axis = 1 ).to_dict () == {"a" : 0 , "b" : 5 }
0 commit comments