I have the following to see if a DataFrame is empty or not:
def emptyframecheck(data_frame):
if data_frame.empty:
raise Exception('An empty dataframe was passed.')
I would like to unit test this but when I run this:
def test_emptyframecheck():
# Given
workitem_df = pd.read_csv(os.path.join(HERE, 'test_csv', 'test.csv'))
# When
emptyframecheck(workitem_df)
# Then
assertTrue('An empty dataframe was passed' in emptyframecheck.exception)
I am getting a global name assertTrue
is not defined. The workitem_df
is simply an empty frame I am passing. Is there something I am missing or a better approach?