From 1572b49fc2858b4ea5ab943807685b35990221a7 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 20 Oct 2025 10:50:41 -0400 Subject: [PATCH 1/4] TST: Catch ResourceWarning under bad combo --- tests/test_doctestplus.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index c88aa9f..eb8ffc2 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -1,8 +1,9 @@ import glob import os +import sys +import warnings from platform import python_version from textwrap import dedent -import sys from packaging.version import Version @@ -25,6 +26,7 @@ PYTEST_LT_6 = Version(pytest.__version__) < Version('6.0.0') +PYTEST_LT_8_5 = Version(pytest.__version__) < Version('8.5.0.dev') def test_ignored_whitespace(testdir): @@ -734,9 +736,17 @@ def f(): testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', '.' ).assertoutcome(passed=0) - testdir.inline_run( - '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' - ).assertoutcome(passed=2) + if os.name == "nt" and python_version() == "3.14.0" and not PYTEST_LT_8_5: + with warnings.catch_warnings(): + # unclosed file pytest.EXE + warnings.filterwarnings("ignore", category=ResourceWarning) + testdir.inline_run( + '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' + ).assertoutcome(passed=2) + else: + testdir.inline_run( + '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' + ).assertoutcome(passed=2) def test_ignore_glob_option(testdir): From acf6ea7abdd007b29c5bcb974b6f27f77ac69f44 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 20 Oct 2025 11:35:01 -0400 Subject: [PATCH 2/4] Fix indent --- tests/test_doctestplus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index eb8ffc2..639ea5b 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -740,9 +740,9 @@ def f(): with warnings.catch_warnings(): # unclosed file pytest.EXE warnings.filterwarnings("ignore", category=ResourceWarning) - testdir.inline_run( - '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' - ).assertoutcome(passed=2) + testdir.inline_run( + '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' + ).assertoutcome(passed=2) else: testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' From 42d37ffc5b9fd4f47d6b2dd74347321c99126e66 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 20 Oct 2025 11:45:50 -0400 Subject: [PATCH 3/4] TST: Relax warning ignore because it mutated --- tests/test_doctestplus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index 639ea5b..5a8ed6c 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -738,8 +738,8 @@ def f(): ).assertoutcome(passed=0) if os.name == "nt" and python_version() == "3.14.0" and not PYTEST_LT_8_5: with warnings.catch_warnings(): - # unclosed file pytest.EXE - warnings.filterwarnings("ignore", category=ResourceWarning) + # ResourceWarning unclosed file pytest.EXE --> PytestUnraisableExceptionWarning + warnings.filterwarnings("ignore") testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' ).assertoutcome(passed=2) From 7f1568cd59eec6e4b48781db13fd8cd665c1c9fc Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 20 Oct 2025 11:52:59 -0400 Subject: [PATCH 4/4] Move ignore to the correct line --- tests/test_doctestplus.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index 5a8ed6c..5ef8700 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -732,21 +732,19 @@ def f(): testdir.makefile('.rst', foo='>>> 1+1\n2') testdir.inline_run('--doctest-plus').assertoutcome(passed=2) - testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) - testdir.inline_run( - '--doctest-plus', '--doctest-rst', '--ignore', '.' - ).assertoutcome(passed=0) if os.name == "nt" and python_version() == "3.14.0" and not PYTEST_LT_8_5: with warnings.catch_warnings(): # ResourceWarning unclosed file pytest.EXE --> PytestUnraisableExceptionWarning warnings.filterwarnings("ignore") - testdir.inline_run( - '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' - ).assertoutcome(passed=2) + testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) else: - testdir.inline_run( - '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' - ).assertoutcome(passed=2) + testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) + testdir.inline_run( + '--doctest-plus', '--doctest-rst', '--ignore', '.' + ).assertoutcome(passed=0) + testdir.inline_run( + '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' + ).assertoutcome(passed=2) def test_ignore_glob_option(testdir):