summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2024-06-13 00:47:58 +0200
committerGitHub <noreply@github.com>2024-06-13 00:47:58 +0200
commit738180d24091b459830ffae2c4f532a711aa2418 (patch)
treea606a7d27f897213fdb103ca2245d92f420e77db /test
parentFix Linux Sector count Fact (#81246) (diff)
downloadansible-738180d24091b459830ffae2c4f532a711aa2418.tar.xz
ansible-738180d24091b459830ffae2c4f532a711aa2418.zip
ansible-test - Fix unit test coverage collection (#83433)
Diffstat (limited to 'test')
-rw-r--r--test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
index 577a498e25..efc8e93193 100644
--- a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
+++ b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
@@ -53,6 +53,12 @@ def pytest_configure():
def coverage_exit(*args, **kwargs):
for instance in coverage_instances:
+ # skip coverage instances which have no collector, or the collector is not the active collector
+ # this avoids issues with coverage 7.4.0+ when tests create subprocesses which inherit our overridden os._exit method
+ # pylint: disable=protected-access
+ if not instance._collector or not instance._collector._collectors or instance._collector != instance._collector._collectors[-1]:
+ continue
+
instance.stop()
instance.save()