pytest-mock icon indicating copy to clipboard operation
pytest-mock copied to clipboard

Thin-wrapper around the mock package for easier use with pytest

Results 19 pytest-mock issues
Sort by recently updated
recently updated
newest added

Hi, I wrote a test that calls a MagicMock() with a list of bytes, then uses assert_has_calls with a different argument (list of strings). Here is pytest's output: ``` def...

- I have the following `TestGenerateAaliDict` class that contains 2 tests. - Each of the test contained in the class will pass if run individually (comment the others) - Whenever...

question

Spy does not work on frozen dataclasses, it would be nice if it did (for instance, by using `object.__setattr__(obj, name, spy)` ```python from dataclasses import dataclass from typing import Callable...

enhancement

Hi, I couldn't quite figure out how to un-spy a spied method yet. I'm not sure if it's even possible after browsing through the source code. ```python spy_foo = mocker.spy(module,...

This would match the behaviour of the equivalent methods in [`mock`](https://github.com/python/cpython/blob/main/Lib/unittest/mock.py#L1687) Currently, I can pass `new_callable=AsyncMock` to make it work, but then mypy type checking fails because the type hints...

help wanted

Mock without specs is so forgiving that people often write tests whose asserts do nothing This is mainly because the apu of mock is severely flawed and error-prone

enhancement

With the growing use of `asyncio`, we need ways to mock Coroutines. Currently, `mock` and `unittest.mock` do not support creating specs for coroutines (AsyncMock is being added in python 3.8)....

#### Capture return value **NOTE: already implemented in 1.11** ```python class SomeClass: def method(self, a): return a * 2 def facade(self): self.method(4) return 'Done' def test_some_class(mocker): spy = mocker.spy(SomeClass, 'method')...

enhancement

> Just to add to this the `RuntimeError` was removed in CPython and mock 3.0.0 due to similar concerns raised in #137 . Upstream issue : https://bugs.python.org/issue36366 . _Originally posted...