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

fixture 'mocker' not found

Open kevinjyh opened this issue 3 years ago • 2 comments

I am new to pytest. After "clone github" repo, "pip install -e .", and "pytest --durations=0" I got the following error messages: tests/test_mocking_constant_mocker.py, line 6 tests/test_mocking_constant_mocker.py, line 14 tests/test_slow_class.py, line 4 tests/test_slow_function.py, line 12 ... E fixture 'mocker' not found

How can I add pytest fixture'mocker' ErrorMsgs.txt ?

kevinjyh avatar Sep 29 '21 11:09 kevinjyh

Try installing pytest-mock manually

pip install pytest-mock

changhsinlee avatar Sep 29 '21 12:09 changhsinlee

If you're using a venv then the above alone won't work. I needed to install pytest-mock at the user level:

pip install --user pytest-mock

Then this worked for me when running pytest inside my venv.

I wish I could explain why that fixed it :thinking:

techotron avatar Mar 09 '22 14:03 techotron