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/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 ede8346..2e7e58f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,10 @@ -from functools import partial import textwrap +from functools import partial from packaging.version import Version import pytest import numpy as np - # 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"): 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)