Skip to content

Commit 3db2e04

Browse files
authored
🧪 Hide false negative warnings by coveragepy (ansible#16021)
They are only surfaced under pytest 8.4, with `pytest-cov` and `pytest-xdist` being both active [[1]]. Or equivalent situations This is a follow-up for ansible#16015 which attempted ignoring the warning on the runtime level in pytest. Instead, the patch tells `coveragepy` not to emit said warnings in the first place. [1]: pytest-dev/pytest-cov#693
1 parent db874f5 commit 3db2e04

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

.coveragerc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ exclude_also =
1717

1818
[run]
1919
branch = True
20+
# NOTE: `disable_warnings` is needed when `pytest-cov` runs in tandem
21+
# NOTE: with `pytest-xdist`. These warnings are false negative in this
22+
# NOTE: context.
23+
#
24+
# NOTE: It's `coveragepy` that emits the warnings and previously they
25+
# NOTE: wouldn't get on the radar of `pytest`'s `filterwarnings`
26+
# NOTE: mechanism. This changed, however, with `pytest >= 8.4`. And
27+
# NOTE: since we set `filterwarnings = error`, those warnings are being
28+
# NOTE: raised as exceptions, cascading into `pytest`'s internals and
29+
# NOTE: causing tracebacks and crashes of the test sessions.
30+
#
31+
# Ref:
32+
# * https://github.com/pytest-dev/pytest-cov/issues/693
33+
# * https://github.com/pytest-dev/pytest-cov/pull/695
34+
# * https://github.com/pytest-dev/pytest-cov/pull/696
35+
disable_warnings =
36+
module-not-measured
2037
omit =
2138
awx/main/migrations/*
2239
awx/settings/defaults.py

pytest.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ markers =
1515
filterwarnings =
1616
error
1717

18-
# Breaks coverage combined with pytest-mp, surfacing as an unhandled error outside of test scope
19-
ignore:Module awx was previously imported, but not measured:coverage.exceptions.CoverageWarning
20-
2118
# FIXME: Upgrade protobuf https://github.com/protocolbuffers/protobuf/issues/15077
2219
once:Type google._upb._message.* uses PyType_Spec with a metaclass that has custom tp_new:DeprecationWarning
2320

0 commit comments

Comments
 (0)