]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116622: Enable `test_doctest` on platforms that don't support subprocesses (#116758)
authorMalcolm Smith <smith@chaquo.com>
Tue, 9 Apr 2024 11:40:58 +0000 (12:40 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Apr 2024 11:40:58 +0000 (14:40 +0300)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/test_doctest/test_doctest.py

index dd8cc9be3a4a8aa14483f3dac893d903d89eb8af..0a2a016fff13e5a4bf63998eeb83eb037ee78361 100644 (file)
@@ -18,8 +18,12 @@ import types
 import contextlib
 
 
-if not support.has_subprocess_support:
-    raise unittest.SkipTest("test_CLI requires subprocess support.")
+def doctest_skip_if(condition):
+    def decorator(func):
+        if condition and support.HAVE_DOCSTRINGS:
+            func.__doc__ = ">>> pass  # doctest: +SKIP"
+        return func
+    return decorator
 
 
 # NOTE: There are some additional tests relating to interaction with
@@ -466,7 +470,7 @@ We'll simulate a __file__ attr that ends in pyc:
     >>> tests = finder.find(sample_func)
 
     >>> print(tests)  # doctest: +ELLIPSIS
-    [<DocTest sample_func from test_doctest.py:33 (1 example)>]
+    [<DocTest sample_func from test_doctest.py:37 (1 example)>]
 
 The exact name depends on how test_doctest was invoked, so allow for
 leading path components.
@@ -2966,6 +2970,7 @@ Check doctest with a non-ascii filename:
     TestResults(failed=1, attempted=1)
     """
 
+@doctest_skip_if(not support.has_subprocess_support)
 def test_CLI(): r"""
 The doctest module can be used to run doctests against an arbitrary file.
 These tests test this CLI functionality.