Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Authors
=======

* GruffElixir - https://github.com/GruffElixir
* Marc Schlaich - https://github.com/schlamar (\http://www.schlamar.org)
* Rick van Hattem - http://wol.ph
* Buck Evan - https://github.com/bukzor
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog
=========

* Fixed no_cover markers and fixtures when coverage is disabled with --no-cov.
Fixes #590.

7.1.0 (2026-03-21)
------------------

Expand Down
3 changes: 3 additions & 0 deletions src/pytest_cov/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ def pytest_terminal_summary(self, terminalreporter):

@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(self, item):
if self._disabled or self.cov_controller is None:
yield
return
if item.get_closest_marker('no_cover') or 'no_cover' in getattr(item, 'fixturenames', ()):
self.cov_controller.pause()
yield
Expand Down
14 changes: 14 additions & 0 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,20 @@ def test_basic():
result.stdout.fnmatch_lines(['mod* 2 * 1 * 50% * 2'])


def test_no_cover_marker_with_no_cov(testdir):
script = testdir.makepyfile(
"""
import pytest

@pytest.mark.no_cover
def test_basic():
pass
"""
)
result = testdir.runpytest('-p', 'pytest_cov.plugin', '-v', '--cov=.', '--no-cov', script)
assert result.ret == 0


def test_no_cover_fixture(testdir):
testdir.makepyfile(mod=MODULE)
script = testdir.makepyfile(
Expand Down