From 3db2e04efe00c8fd0265de1f2a1f7388da95fd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=87=BA=F0=9F=87=A6=20Sviatoslav=20Sydorenko=20=28?= =?UTF-8?q?=D0=A1=D0=B2=D1=8F=D1=82=D0=BE=D1=81=D0=BB=D0=B0=D0=B2=20=D0=A1?= =?UTF-8?q?=D0=B8=D0=B4=D0=BE=D1=80=D0=B5=D0=BD=D0=BA=D0=BE=29?= Date: Thu, 12 Jun 2025 17:45:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Hide=20false=20negative=20warnin?= =?UTF-8?q?gs=20by=20`coveragepy`=20(#16021)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #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 --- .coveragerc | 17 +++++++++++++++++ pytest.ini | 3 --- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.coveragerc b/.coveragerc index caafe9b6df..14aa98d8f9 100644 --- a/.coveragerc +++ b/.coveragerc @@ -17,6 +17,23 @@ exclude_also = [run] branch = True +# NOTE: `disable_warnings` is needed when `pytest-cov` runs in tandem +# NOTE: with `pytest-xdist`. These warnings are false negative in this +# NOTE: context. +# +# NOTE: It's `coveragepy` that emits the warnings and previously they +# NOTE: wouldn't get on the radar of `pytest`'s `filterwarnings` +# NOTE: mechanism. This changed, however, with `pytest >= 8.4`. And +# NOTE: since we set `filterwarnings = error`, those warnings are being +# NOTE: raised as exceptions, cascading into `pytest`'s internals and +# NOTE: causing tracebacks and crashes of the test sessions. +# +# Ref: +# * https://github.com/pytest-dev/pytest-cov/issues/693 +# * https://github.com/pytest-dev/pytest-cov/pull/695 +# * https://github.com/pytest-dev/pytest-cov/pull/696 +disable_warnings = + module-not-measured omit = awx/main/migrations/* awx/settings/defaults.py diff --git a/pytest.ini b/pytest.ini index 512da67f81..5e4bf72dd5 100644 --- a/pytest.ini +++ b/pytest.ini @@ -15,9 +15,6 @@ markers = filterwarnings = error - # Breaks coverage combined with pytest-mp, surfacing as an unhandled error outside of test scope - ignore:Module awx was previously imported, but not measured:coverage.exceptions.CoverageWarning - # FIXME: Upgrade protobuf https://github.com/protocolbuffers/protobuf/issues/15077 once:Type google._upb._message.* uses PyType_Spec with a metaclass that has custom tp_new:DeprecationWarning