Skip to content

Commit 22b25d1

Browse files
mhsmithsobolevn
andauthored
gh-116622: Enable test_doctest on platforms that don't support subprocesses (#116758)
Co-authored-by: Nikita Sobolev <[email protected]>
1 parent f2132fc commit 22b25d1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/test/test_doctest/test_doctest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
import contextlib
1919

2020

21-
if not support.has_subprocess_support:
22-
raise unittest.SkipTest("test_CLI requires subprocess support.")
21+
def doctest_skip_if(condition):
22+
def decorator(func):
23+
if condition and support.HAVE_DOCSTRINGS:
24+
func.__doc__ = ">>> pass # doctest: +SKIP"
25+
return func
26+
return decorator
2327

2428

2529
# NOTE: There are some additional tests relating to interaction with
@@ -466,7 +470,7 @@ def basics(): r"""
466470
>>> tests = finder.find(sample_func)
467471
468472
>>> print(tests) # doctest: +ELLIPSIS
469-
[<DocTest sample_func from test_doctest.py:33 (1 example)>]
473+
[<DocTest sample_func from test_doctest.py:37 (1 example)>]
470474
471475
The exact name depends on how test_doctest was invoked, so allow for
472476
leading path components.
@@ -2966,6 +2970,7 @@ def test_unicode(): """
29662970
TestResults(failed=1, attempted=1)
29672971
"""
29682972

2973+
@doctest_skip_if(not support.has_subprocess_support)
29692974
def test_CLI(): r"""
29702975
The doctest module can be used to run doctests against an arbitrary file.
29712976
These tests test this CLI functionality.

0 commit comments

Comments
 (0)