Skip to content

AttributeError: 'Function' object has no attribute 'get_marker' #252

Closed
@rossmacarthur

Description

@rossmacarthur

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions