This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
TL/DR: | |
Never instantiate mock.Mock() directly. | |
Instead use either mock.create_autospec(YourClass) OR mock.patch('YourClass', autospec=True). | |
The "spec" feature of Mock is great, it helps avoid your mocked API drifting out of sync with your real API. | |
But there is a gotcha if you are mocking classes directly - it's easy to mock the class but you need to | |
ensure the spec applies to the *instance* as well. | |
""" |