As I mentioned on that issue, I believe the problem is that stop() is called two times in a row without start() being called in between (but I haven't reinvestigated since then). Assuming this is the issue, I would suggest making these functions idempotent.
Expected vs actual result
Reproducer
$ ls .
__pycache__ test.py
$ cat test.py
import pytest
@pytest.mark.no_cover
def test():
pass
$ pytest --cov=. --no-cov test.py
========================================================================== test session starts ==========================================================================
platform darwin -- Python 3.9.15, pytest-7.3.0, pluggy-1.0.0
rootdir: /private/tmp/test
plugins: anyio-3.6.1, hypothesis-6.70.1, xonsh-0.13.4, pudb-0.7.0, flaky-3.7.0, mock-3.10.0, regressions-2.4.2, flake8-1.1.1, doctestplus-0.12.1, cov-4.0.0, flakes-4.0.5, datadir-1.4.1, aiohttp-0.3.0
collected 1 item
test.py F [100%]
=============================================================================== FAILURES ================================================================================
_________________________________________________________________________________ test __________________________________________________________________________________
self = <pytest_cov.plugin.CovPlugin object at 0x109aa7a60>, item = <Function test>
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(self, item):
if (item.get_closest_marker('no_cover')
or 'no_cover' in getattr(item, 'fixturenames', ())):
> self.cov_controller.pause()
E AttributeError: 'NoneType' object has no attribute 'pause'
/Users/aaronmeurer/anaconda3/lib/python3.9/site-packages/pytest_cov/plugin.py:366: AttributeError
======================================================================== short test summary info ========================================================================
FAILED test.py::test - AttributeError: 'NoneType' object has no attribute 'pause'
=========================================================================== 1 failed in 0.16s ===========================================================================
Versions
Output of relevant packages pip list, python --version, pytest --version etc.
Make sure you include complete output of tox if you use it (it will show versions of various things).
$ pytest --version
pytest 7.3.0
$ coverage --version
Coverage.py, version 7.2.3 with C extension
Full documentation is at https://coverage.readthedocs.io/en/7.2.3
Summary
If you have a test with
@pytest.mark.no_cover
and use--no-cov
, the test fails withAttributeError: 'NoneType' object has no attribute 'pause'
.This was mentioned in https://github.com/pytest-dev/pytest-cov/issues/562 but didn't get the attention I was hoping for, so I'm opening a new issue here.
As I mentioned on that issue, I believe the problem is that
stop()
is called two times in a row withoutstart()
being called in between (but I haven't reinvestigated since then). Assuming this is the issue, I would suggest making these functions idempotent.Expected vs actual result
Reproducer
Versions
Output of relevant packages
pip list
,python --version
,pytest --version
etc.Make sure you include complete output of
tox
if you use it (it will show versions of various things).