First of all, love your book, it’s really helped me get started testing in python.
I’m having a problem understanding where monkeypatch and mock should be used. From what I can understand, both are useful in that they undo what you’ve done after using pytests fixtures, however, monkeypatch is included in pytest and mock is an additional plugin.
Monkeypatch can apparently add and delete attributes, set and delete dictionary items, set and delete environment variables, and mess with the path.
Mock is apparently a wrapper around patch, mock and magicmock from the mock library.
In your book, you talk about each of them separately, but to my beginner mind, their utility is maximized while being used together. Create a mock or magicmock instance with patch that and then add or delete attributes as needed with monkeypatch.
Most of the mocking/monkey-patching guides online use the monkeypatch plugin with the mock module or just monkeypatching using python’s everything is an object ideal. It seems it would be most useful to have them as fixtures, where the setup and tear down are automated by pytest.
Am I incorrect in thinking this? Thanks