fixture 'mocker' not found
See original GitHub issueI haven’t looked too closely into this bug yet, but the error itself is strange, given that it explicitly lists ‘mocker’ as one of the available fixtures.
I had run tox -r previously and everything passed. Then I upgraded
- pytest (2.9.2) -> 3.0.3
- pytest-mock (1.2) -> 1.4.0
And started seeing this failure.
@pytest.fixture
def request(mocker):
E fixture 'mocker' not found
> available fixtures: cache, capfd, capsys, doctest_namespace, mock, mocker, monkeypatch, pytestconfig, record_xml_property, recwarn, request, requests_get, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
Code looks something like this:
import pytest
from mock import Mock, sentinel
from requests import codes
@pytest.fixture
def request(mocker):
return Mock((), url='https://test-url.com:8000', cookies=None, headers={})
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Unable to find fixture "mocker" (pytest-mock) when running ...
However, when I try to run the test directly using pytest from within my venv, everything works as expected. $ py.test --cov esmigrate...
Read more >E fixture 'mocker' not found - Emre Bayram
So I had to solve it; here is the solution: On your terminal window click: Edit -> Preferences And then on the opening...
Read more >Add optional requirement "pystest-mock" to list of dependencies
... all dependencies specified in the installation wiki-page, a number of tests fail with the following error E fixture 'mocker' not found.
Read more >Tips about pytest - Robin on Linux
After running pytest, it reported: E fixture 'mocker' not found > available fixtures: cache, capfd, capsys, doctest_namespace, mock, mocker, ...
Read more >Unable to find fixture "mocker" (pytest-mock) when running ...
EEEE ... file /path/to/test_cli.py, line 63 def test_cli_with_init_cmd_fails_with_db_error(runner, mocker, context): E fixture 'mocker' not found ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @Dishanka13, did you install
pytest-mock
usingpip install pytest-mock
?You can verify that by calling
pip list
Not sure if still relevant but I found that I had to install pytest-mock into my user-level general python module-library (~/.local/lib/python*) when running from a venv, even though that venv had the pytest-mock package installed and relevant executables ran from the venv.