From b92fa5eacbfabb8a200c7897a55a96ff453d3725 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Tue, 28 Oct 2025 20:48:40 -0400 Subject: [PATCH 1/3] TST: verbose output for debugging and globally ignore ResourceWarning TST: Revert #307 --- .github/workflows/python-tests.yml | 1 + setup.cfg | 3 +++ tests/test_doctestplus.py | 10 +--------- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 70a4b0d..5e93fe4 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -64,6 +64,7 @@ jobs: - os: windows-latest python-version: '3.14' toxenv: py314-test-pytestdev + posargs: -v - os: macos-latest python-version: '3.14' toxenv: py314-test-pytestdev diff --git a/setup.cfg b/setup.cfg index b15c6c6..61be62b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,6 +61,9 @@ filterwarnings = # For pytest-asyncio deprecations that is expected to be resolved upstream # https://github.com/pytest-dev/pytest-asyncio/issues/924 ignore:The configuration option "asyncio_default_fixture_loop_scope":pytest.PytestDeprecationWarning + # Windows + Python 3.14 + pytest-dev have ResourceWarning, see + # https://github.com/scientific-python/pytest-doctestplus/issues/305 + ignore::ResourceWarning [flake8] max-line-length = 100 diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index 5ef8700..932ec94 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -1,7 +1,6 @@ import glob import os import sys -import warnings from platform import python_version from textwrap import dedent @@ -26,7 +25,6 @@ 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): @@ -732,13 +730,7 @@ def f(): testdir.makefile('.rst', foo='>>> 1+1\n2') testdir.inline_run('--doctest-plus').assertoutcome(passed=2) - 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').assertoutcome(passed=3) - else: - testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) + testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', '.' ).assertoutcome(passed=0) From 4227e18f086ad4021bda8e72ce74edc280b44895 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Wed, 29 Oct 2025 10:38:41 -0400 Subject: [PATCH 2/3] TST: Localize ResourceWarning ignore. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Brigitta Sipőcz --- setup.cfg | 3 --- tests/conftest.py | 12 +++++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 61be62b..b15c6c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -61,9 +61,6 @@ filterwarnings = # For pytest-asyncio deprecations that is expected to be resolved upstream # https://github.com/pytest-dev/pytest-asyncio/issues/924 ignore:The configuration option "asyncio_default_fixture_loop_scope":pytest.PytestDeprecationWarning - # Windows + Python 3.14 + pytest-dev have ResourceWarning, see - # https://github.com/scientific-python/pytest-doctestplus/issues/305 - ignore::ResourceWarning [flake8] max-line-length = 100 diff --git a/tests/conftest.py b/tests/conftest.py index ede8346..095a188 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,13 @@ -from functools import partial +import sys import textwrap +from functools import partial from packaging.version import Version +from platform import python_version import pytest import numpy as np +PYTEST_LT_8_5 = Version(pytest.__version__) < Version('8.5.0.dev') # Keep this until we require numpy to be >=2.0 or there is a directive in doctestplus # to support multiple ways of repr @@ -53,3 +56,10 @@ def make(*args, **kwargs): return testdir.makefile('.rst', *args, **kwargs) return make + + +# Windows + Python 3.14.0 + pytest-dev have ResourceWarning, see +# https://github.com/scientific-python/pytest-doctestplus/issues/305 +def pytest_runtestloop(session): + if sys.platform == 'win32' and python_version() == "3.14.0" and not PYTEST_LT_8_5: + session.add_marker(pytest.mark.filterwarnings('ignore::ResourceWarning')) From 657887dfc4461d1e841ab8f0a2484e9486beb309 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Fri, 31 Oct 2025 21:35:40 -0400 Subject: [PATCH 3/3] TST: Try move Windows stuff to root level conftest.py --- conftest.py | 14 ++++++++++++++ tests/conftest.py | 11 ----------- 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 conftest.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..2a7c0aa --- /dev/null +++ b/conftest.py @@ -0,0 +1,14 @@ +import sys +from packaging.version import Version +from platform import python_version + +import pytest + +PYTEST_LT_8_5 = Version(pytest.__version__) < Version('8.5.0.dev') + + +# Windows + Python 3.14.0 + pytest-dev have ResourceWarning, see +# https://github.com/scientific-python/pytest-doctestplus/issues/305 +def pytest_runtestloop(session): + if sys.platform == 'win32' and python_version() == "3.14.0" and not PYTEST_LT_8_5: + session.add_marker(pytest.mark.filterwarnings('ignore::ResourceWarning')) diff --git a/tests/conftest.py b/tests/conftest.py index 095a188..2e7e58f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,14 +1,10 @@ -import sys import textwrap from functools import partial from packaging.version import Version -from platform import python_version import pytest import numpy as np -PYTEST_LT_8_5 = Version(pytest.__version__) < Version('8.5.0.dev') - # Keep this until we require numpy to be >=2.0 or there is a directive in doctestplus # to support multiple ways of repr if Version(np.__version__) >= Version("2.0.dev"): @@ -56,10 +52,3 @@ def make(*args, **kwargs): return testdir.makefile('.rst', *args, **kwargs) return make - - -# Windows + Python 3.14.0 + pytest-dev have ResourceWarning, see -# https://github.com/scientific-python/pytest-doctestplus/issues/305 -def pytest_runtestloop(session): - if sys.platform == 'win32' and python_version() == "3.14.0" and not PYTEST_LT_8_5: - session.add_marker(pytest.mark.filterwarnings('ignore::ResourceWarning'))