vendredi 22 mars 2019

Inspect class object of mocked method

I am writing a test of a function which sends a pandas dataframe to a sql database using the dataframe's to_sql() method.

To avoid actually sending anything, I am mocking the method using mock.patch('pandas.DataFrame.to_sql').

I would like to see the state of the dataframe at the time of calling to_sql(). Is there any way to do this using the mock? I.e., is it aware of the object from which the mocked function was called?

The function I am testing is not currently returning anything. Would that be necessary to check the dataframe? E.g. returning the dataframe after the to_sql() call? I don't need the return value for anything other than making this test, so would prefer another way if possible.

Aucun commentaire:

Enregistrer un commentaire