From a3881db34ec2d327623a5408adbfc243ea70ef07 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 13 Dec 2024 08:21:34 +0000 Subject: [PATCH] move lsof warning to something ignorable and ignore it --- pyproject.toml | 3 +++ src/_pytest/pytester.py | 4 ++-- src/_pytest/warning_types.py | 5 +++++ src/pytest/__init__.py | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dce6a0870e1..246c04d5990 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -403,6 +403,9 @@ filterwarnings = [ "ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", # https://github.com/pytest-dev/execnet/pull/127 "ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning", + # https://github.com/pytest-dev/pytest/issues/2366 + # https://github.com/pytest-dev/pytest/pull/13057 + "default:.*:pytest.PytestFDWarning", ] pytester_example_dir = "testing/example_scripts" markers = [ diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 412d850d2da..59839562031 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -65,7 +65,7 @@ from _pytest.reports import CollectReport from _pytest.reports import TestReport from _pytest.tmpdir import TempPathFactory -from _pytest.warning_types import PytestWarning +from _pytest.warning_types import PytestFDWarning if TYPE_CHECKING: @@ -188,7 +188,7 @@ def pytest_runtest_protocol(self, item: Item) -> Generator[None, object, object] "*** function {}:{}: {} ".format(*item.location), "See issue #2366", ] - item.warn(PytestWarning("\n".join(error))) + item.warn(PytestFDWarning("\n".join(error))) # used at least by pytest-xdist plugin diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index b8e9998cd2e..119fa490e66 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -123,6 +123,11 @@ def format(self, **kwargs: Any) -> _W: return self.category(self.template.format(**kwargs)) +@final +class PytestFDWarning(PytestWarning): + pass + + def warn_explicit_for(method: FunctionType, message: PytestWarning) -> None: """ Issue the warning :param:`message` for the definition of the given :param:`method` diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index f0c3516f4cc..70096d6593e 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -77,6 +77,7 @@ from _pytest.warning_types import PytestConfigWarning from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import PytestExperimentalApiWarning +from _pytest.warning_types import PytestFDWarning from _pytest.warning_types import PytestRemovedIn9Warning from _pytest.warning_types import PytestUnhandledThreadExceptionWarning from _pytest.warning_types import PytestUnknownMarkWarning @@ -124,6 +125,7 @@ "PytestConfigWarning", "PytestDeprecationWarning", "PytestExperimentalApiWarning", + "PytestFDWarning", "PytestPluginManager", "PytestRemovedIn9Warning", "PytestUnhandledThreadExceptionWarning",