File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 11# testcase.py
2+ import pandas
23import pandas as pd
34import unittest
45
@@ -44,17 +45,19 @@ def setDownClass(cls):
4445 def assertNotNullItemsInColumn (self , df : pd .DataFrame , column : str ):
4546 nul_values = df [column ].isnull ().sum ()
4647 if nul_values > 0 :
47- raise AssertionError (f"column { column } has { nul_values } null values, expected 0" )
48+ raise AssertionError (f"column { column } has { nul_values } null values, expected 0\n { self . addDFtoLog ( df ) } " )
4849
4950 def assertCustomNullItemsInColumn (self , df : pd .DataFrame , column : str , target : int ):
5051 nul_values = df [column ].isnull ().sum ()
5152 if nul_values != target :
52- raise AssertionError (f"column { column } has { nul_values } null values, expected { target } " )
53+ raise AssertionError (f"column { column } has { nul_values } null values, expected { target } \n { self . addDFtoLog ( df ) } " )
5354
5455 def assertNoRows (self , df : pd .DataFrame ):
5556 self .assertNRows (df , 0 )
5657
5758 def assertNRows (self , df : pd .DataFrame , target_rows : int ):
5859 if len (df ) != target_rows :
59- raise AssertionError (f"df has { len (df )} rows, expected { target_rows } " )
60+ raise AssertionError (f"df has { len (df )} rows, expected { target_rows } \n { self . addDFtoLog ( df ) } " )
6061
62+ def addDFtoLog (self , df : pandas .DataFrame ):
63+ return f"\n DF that generated the error:\n { df } "
You can’t perform that action at this time.
0 commit comments