question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fixture 'mocker' not found

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

73reactions
nicoddemuscommented, Feb 20, 2019

Hi @Dishanka13, did you install pytest-mock using pip install pytest-mock?

You can verify that by calling pip list

5reactions
BlackestDawncommented, Dec 6, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found