aboutsummaryrefslogtreecommitdiffstats
path: root/tests/base.py
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-10-28 15:56:34 +0100
committerGravatar Sebastiaan Zeeff <[email protected]>2019-10-28 15:56:34 +0100
commitc5d0eb473a9a1dc486dd2dd60603463435e49da4 (patch)
treee130e17a17bd040f74b0dd275ef70bee033ae391 /tests/base.py
parentMerge pull request #527 from kraktus/compact_free (diff)
Change generation of child mocks
- https://docs.python.org/3/library/unittest.mock.html We previously used an override of the `__new__` method to prevent our custom mock types from instantiating their children with their own type instead of a general mock type like `MagicMock` or `Mock`. As it turns out, the Python documentation suggests another method of doing this that does not involve overriding `__new__`. This commit implements this new method to make sure we're using the idiomatic way of handling this. The suggested method is overriding the `_get_child_mock` method in the subclass. To make our code DRY, I've created a mixin that should come BEFORE the mock type we're subclassing in the MRO. --- In addition, I have also added this new mixin to our `AsyncMock` class to make sure that its `__call__` method returns a proper mock object after it has been awaited. This makes sure that subsequent attribute access on the returned object is mocked as expected.
Diffstat (limited to 'tests/base.py')
0 files changed, 0 insertions, 0 deletions