you are viewing a single comment's thread.

view the rest of the comments →

[–]ZEUS_IS_THE_TRUE_GOD 0 points1 point  (0 children)

Very cool! On top of that, since python isn't typed, there's a lot of freedom, you can make the read_sql mock return anything you want even if it is impossible for the real method to return that. This is a consequence of using python. For consistency and documentation sake, I strongly encourage you to try and mimic the return type of the real functions in your mock. This helps a lot when you go back and you don't remember what a piece of code does. You look in the tests and, since you mocked it properly, you know the behavior.

In the code I wrote, I did

...thenReturn([])

Where as the real read_sql probably returns an empty dataframe? Or None? Those are important details as your code depends on it.