Skip to content

Commit 1572b49

Browse files
authored
TST: Catch ResourceWarning under bad combo
1 parent 5e12021 commit 1572b49

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/test_doctestplus.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import glob
22
import os
3+
import sys
4+
import warnings
35
from platform import python_version
46
from textwrap import dedent
5-
import sys
67

78
from packaging.version import Version
89

@@ -25,6 +26,7 @@
2526

2627

2728
PYTEST_LT_6 = Version(pytest.__version__) < Version('6.0.0')
29+
PYTEST_LT_8_5 = Version(pytest.__version__) < Version('8.5.0.dev')
2830

2931

3032
def test_ignored_whitespace(testdir):
@@ -734,9 +736,17 @@ def f():
734736
testdir.inline_run(
735737
'--doctest-plus', '--doctest-rst', '--ignore', '.'
736738
).assertoutcome(passed=0)
737-
testdir.inline_run(
738-
'--doctest-plus', '--doctest-rst', '--ignore', 'bar.py'
739-
).assertoutcome(passed=2)
739+
if os.name == "nt" and python_version() == "3.14.0" and not PYTEST_LT_8_5:
740+
with warnings.catch_warnings():
741+
# unclosed file pytest.EXE
742+
warnings.filterwarnings("ignore", category=ResourceWarning)
743+
testdir.inline_run(
744+
'--doctest-plus', '--doctest-rst', '--ignore', 'bar.py'
745+
).assertoutcome(passed=2)
746+
else:
747+
testdir.inline_run(
748+
'--doctest-plus', '--doctest-rst', '--ignore', 'bar.py'
749+
).assertoutcome(passed=2)
740750

741751

742752
def test_ignore_glob_option(testdir):

0 commit comments

Comments
 (0)