diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 492fa1c..1e76647 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -67,6 +67,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/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')) 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)