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.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:19
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

10reactions
BaranOrnarlicommented, Feb 13, 2019

conda install pytest; pip install pytest-remotedata>=0.3.1 and things start working.

5reactions
ionelmccommented, Jan 7, 2019

pytest-cov 2.6.1 is released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest AttributeError: 'Function' object has no attribute ' ...
Got this error on a very simple test using pytest version 4.6.3 . On searching, I came across this link where I found...
Read more >
AttributeError: 'Function' object has no attribute 'get_marker' ...
Hi, I'm running into this issue with pytest version 4.3.0 (Python version 3.7.0). Please advise!
Read more >
pytest AttributeError get_marker
AttributeError: 'Function' object has no attribute 'get_marker'. The fix requires update of affiliated pytest-* packages to at least:.
Read more >
AttributeError: “Function”object has no attribute “get marker”
I have tried to follow the documentation but was not able to use urlparse.parse.quote_plus() in Python 3:from urllib.parse import urlparseparams ...
Read more >
'function' object has no attribute 'get' while saving onetoone ...
I am getting : AttributeError: 'function' object has no attribute 'get' while saving onetoone relation in django?
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