pytest-cov: AttributeError: 'Function' object has no attribute 'get_marker'
I just started getting the following error with pytest-cov v2.6.0, pytest v4.1.0 on Python 3.4.6, PyPy, and PyPy3
self = <pytest_cov.plugin.CovPlugin object at 0x110f365c0>, item = <Function test_x>
@compat.hookwrapper
def pytest_runtest_call(self, item):
> if (item.get_marker('no_cover')
or 'no_cover' in getattr(item, 'fixturenames', ())):
E AttributeError: 'Function' object has no attribute 'get_marker'
../.pyenv/versions/3.4.9/envs/venv/lib/python3.4/site-packages/pytest_cov/plugin.py:289: AttributeError
How to replicate
-
Create a virtualenv with Python 3.4.9
-
pip install pytest==4.1.0 pytest-cov==2.6.0
-
Create
something.py
with the following contents:
def test_x():
assert True
- Run
pytest --cov=something something.py
Pytest output
========================================================== test session starts ===========================================================
platform darwin -- Python 3.4.9, pytest-4.1.0, py-1.7.0, pluggy-0.8.0 -- /Users/ross/.pyenv/versions/3.4.9/envs/venv/bin/python
cachedir: .pytest_cache
rootdir: /Users/ross/temp, inifile:
plugins: cov-2.6.0
collected 1 item
something.py::test_x FAILED [100%]
================================================================ FAILURES ================================================================
_________________________________________________________________ test_x _________________________________________________________________
self = <pytest_cov.plugin.CovPlugin object at 0x110f365c0>, item = <Function test_x>
@compat.hookwrapper
def pytest_runtest_call(self, item):
> if (item.get_marker('no_cover')
or 'no_cover' in getattr(item, 'fixturenames', ())):
E AttributeError: 'Function' object has no attribute 'get_marker'
../.pyenv/versions/3.4.9/envs/venv/lib/python3.4/site-packages/pytest_cov/plugin.py:289: AttributeError
---------- coverage: platform darwin, python 3.4.9-final-0 -----------
Name Stmts Miss Cover
----------------------------------
something.py 2 1 50%
======================================================== 1 failed in 0.07 seconds ========================================================
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 19
- Comments: 21 (10 by maintainers)
Commits related to this issue
- Specify pytest version to 4.0.2 version 4.1.0 was updated on PyPI on Jan 6, 2019, which broke pytest-cov https://github.com/pytest-dev/pytest-cov/issues/252 — committed to spice-herald/QETpy by slwatkins 5 years ago
- Pin pytest to previous version Until https://github.com/pytest-dev/pytest-cov/issues/252 get fixed — committed to ticosax/django-fsm-log by ticosax 5 years ago
- Do not hardcode the warning filter The application should control whether warnings should be visible or not. By hardcoding the simplefilter we turn on warnings' visibility for all modules that follow... — committed to IdentityPython/pysaml2 by c00kiemon5ter 5 years ago
- Upping plugin version. Seeing this on test scripts when run from latest docker image: https://github.com/pytest-dev/pytest-cov/issues/252 — committed to wtgee/panoptes-utils by wtgee 5 years ago
- Ensure "pytest-remotedata>=0.3.1" to resolve error Errors: > remote_data = item.get_marker('remote_data') E AttributeError: 'Function' object has no attribute 'get_marker' REF: ... — committed to LSSTDESC/snmachine by tallamjr 4 years ago
- Ensure "pytest-remotedata>=0.3.1" to resolve error Errors: > remote_data = item.get_marker('remote_data') E AttributeError: 'Function' object has no attribute 'get_marker' REF: ... — committed to LSSTDESC/snmachine by tallamjr 4 years ago
conda install pytest
;pip install pytest-remotedata>=0.3.1
and things start working.pytest-cov 2.6.1 is released.
pip install "pytest-remotedata>=0.3.1"
unless you want to redirect to a file (in fish at least). But otherwise, great fix Baran.@nicoddemus It’s also fixed in pytest-remotedata 0.3.1 which @prashant-bansod has installed - based on the stacktrace above, the error @prashant-bansod is seeing is in their testsuite (or whatever
topology.pytest.plugin
is).We are seeing the same error with latest version of
pytest
.OK:
pytest==4.02
withpytest-cov-2.6.0
FAILS:pytest==4.1.0
withpytest-cov-2.6.0