I have a function which returns a dataframe which has rows and columns. here's the function: app.py
def pandas_factory(colnames, rows):
return pd.DataFrame(rows, columns=colnames)
And here is my unit testcase for the same: test_app.py
def test_panda_fact(self):
from dlp.dlp import pandas_factory
df1 = pd.DataFrame({'a': [1, 2], 'b': [3, 4]})
with pytest.raises(TypeError) as er:
mock_open = mock.mock_open(read_data=df1)
with patch('dlp.dlp.pandas_factory', mock_open):
obj = pandas_factory
self.assertTrue(obj)
The testcase runs but am I testing it in the right way?
pandas_factory()to create dataframes so what exactly is it you're trying to test here? Also, hard-coding test cases is generally not a great idea.pandas.DataFramedoes what it is supposed to do? Or the fact thatpandas_factoryobject exists?