File 052-tests-port-pytest_ignore_collect-to-pathlib.patch of Package virt-manager
Subject: tests: port pytest_ignore_collect() to pathlib
From: Pino Toscano ptoscano@redhat.com Mon Jun 30 14:10:16 2025 +0200
Date: Sun Jan 11 00:02:42 2026 +0100:
Git: a5a54036919aa4bc6e7a7918865cabc58a9c70d9
Create a pathlib version of the "path" argument of the
pytest_ignore_collect() hook; this will make it easier to the newer
version that uses pathlib directly.
This makes it possible to simplify the check for filenames to ignore:
since the filename is available, use it to do a quick lookup.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
diff --git a/tests/conftest.py b/tests/conftest.py
index 7ec7adf10..38cb09f1f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,6 +2,7 @@
# See the COPYING file in the top-level directory.
import os
+import pathlib
import pytest
@@ -53,6 +54,7 @@ def pytest_addoption(parser):
def pytest_ignore_collect(path, config):
+ collection_path = pathlib.Path(path)
uitests_requested = config.getoption("--uitests")
# Default --uitests to --verbosity=2
@@ -60,14 +62,14 @@ def pytest_ignore_collect(path, config):
config.option.verbose = max(2, config.option.verbose)
# Unless explicitly requested, ignore these tests
- if "test_dist.py" in str(path):
- return True
- if "test_urls.py" in str(path):
- return True
- if "test_inject.py" in str(path):
+ if collection_path.name in (
+ "test_dist.py",
+ "test_urls.py",
+ "test_inject.py",
+ ):
return True
- uitest_file = "tests/uitests" in str(path)
+ uitest_file = "tests/uitests" in str(collection_path)
if uitest_file and not uitests_requested:
return True
if not uitest_file and uitests_requested: