import sys
import sysconfig
-from test.support import run_unittest, missing_compiler_executable
+from test.support import (
+ run_unittest, missing_compiler_executable, requires_subprocess
+)
from distutils.command.build_clib import build_clib
from distutils.errors import DistutilsSetupError
self.assertRaises(DistutilsSetupError, cmd.finalize_options)
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
+ @requires_subprocess()
def test_run(self):
pkg_dir, dist = self.create_dist()
cmd = build_clib(dist)
def build_ext(self, *args, **kwargs):
return build_ext(*args, **kwargs)
+ @support.requires_subprocess()
def test_build_ext(self):
cmd = support.missing_compiler_executable()
if cmd is not None:
cmd.run()
self.assertEqual(cmd.compiler, 'unix')
+ @support.requires_subprocess()
def test_get_outputs(self):
cmd = support.missing_compiler_executable()
if cmd is not None:
from distutils.errors import DistutilsFileError
from distutils.tests import support
-from test.support import run_unittest
+from test.support import run_unittest, requires_subprocess
class BuildPyTestCase(support.TempdirManager,
self.fail("failed package_data test when package_dir is ''")
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ @requires_subprocess()
def test_byte_compile(self):
project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
os.chdir(project_dir)
['boiledeggs.%s.pyc' % sys.implementation.cache_tag])
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ @requires_subprocess()
def test_byte_compile_optimized(self):
project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
os.chdir(project_dir)
import os
import sys
import sysconfig
-from test.support import run_unittest, missing_compiler_executable
+from test.support import (
+ run_unittest, missing_compiler_executable, requires_subprocess
+)
from distutils.command.config import dump_file, config
from distutils.tests import support
self.assertEqual(len(self._logs), numlines+1)
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
+ @requires_subprocess()
def test_search_cpp(self):
cmd = missing_compiler_executable(['preprocessor'])
if cmd is not None:
import unittest
import site
-from test.support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest, requires_subprocess
from distutils import sysconfig
from distutils.command.install import install, HAS_USER_SITE
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
self.assertEqual(found, expected)
+ @requires_subprocess()
def test_record_extensions(self):
cmd = test_support.missing_compiler_executable()
if cmd is not None:
from distutils.extension import Extension
from distutils.tests import support
from distutils.errors import DistutilsOptionError
-from test.support import run_unittest
+from test.support import run_unittest, requires_subprocess
class InstallLibTestCase(support.TempdirManager,
self.assertEqual(cmd.optimize, 2)
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ @requires_subprocess()
def test_byte_compile(self):
project_dir, dist = self.create_dist()
os.chdir(project_dir)
inputs = cmd.get_inputs()
self.assertEqual(len(inputs), 2, inputs)
+ @requires_subprocess()
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
dist = self.create_dist()[1]
import stat
import sys
import unittest.mock
-from test.support import run_unittest, unix_shell
+from test.support import run_unittest, unix_shell, requires_subprocess
from test.support import os_helper
from distutils.spawn import find_executable
from distutils.errors import DistutilsExecError
from distutils.tests import support
+
+@requires_subprocess()
class SpawnTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
from distutils import sysconfig
from distutils.ccompiler import get_default_compiler
from distutils.tests import support
-from test.support import run_unittest, swap_item
+from test.support import run_unittest, swap_item, requires_subprocess
from test.support.os_helper import TESTFN
from test.support.warnings_helper import check_warnings
self.assertIsNotNone(vars['SO'])
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
+ @requires_subprocess()
def test_customize_compiler_before_get_config_vars(self):
# Issue #21923: test that a Distribution compiler
# instance can be called without an explicit call to
shutil.rmtree(tmpdir)
@unittest.skipIf(sys.executable is None, 'sys.executable required')
+ @unittest.skipIf(
+ sys.platform == 'emscripten', 'requires working subprocess'
+ )
def test_load_grammar_from_subprocess(self):
tmpdir = tempfile.mkdtemp()
tmpsubdir = os.path.join(tmpdir, 'subdir')
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
"requires_IEEE_754", "requires_zlib",
"has_fork_support", "requires_fork",
+ "has_subprocess_support", "requires_subprocess",
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
"check__all__", "skip_if_buggy_ucrt_strfptime",
"check_disallow_instantiation",
# sys
- "is_jython", "is_android", "is_emscripten",
+ "is_jython", "is_android", "is_emscripten", "is_wasi",
"check_impl_detail", "unix_shell", "setswitchinterval",
# network
"open_urlresource",
else:
unix_shell = None
-# wasm32-emscripten is POSIX-like but does not provide a
-# working fork() or subprocess API.
+# wasm32-emscripten and -wasi are POSIX-like but do not
+# have subprocess or fork support.
is_emscripten = sys.platform == "emscripten"
+is_wasi = sys.platform == "wasi"
-has_fork_support = hasattr(os, "fork") and not is_emscripten
+has_fork_support = hasattr(os, "fork") and not is_emscripten and not is_wasi
def requires_fork():
return unittest.skipUnless(has_fork_support, "requires working os.fork()")
+has_subprocess_support = not is_emscripten and not is_wasi
+
+def requires_subprocess():
+ """Used for subprocess, os.spawn calls"""
+ return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
+
+
# Define the URL of a dedicated HTTP server for the network tests.
# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
TEST_HTTP_URL = "http://www.pythontest.net"
if 'PYTHONHOME' in os.environ:
__cached_interp_requires_environment = True
return True
+ # cannot run subprocess, assume we don't need it
+ if not support.has_subprocess_support:
+ __cached_interp_requires_environment = False
+ return False
# Try running an interpreter with -E to see if it works or not.
try:
# Executing the interpreter in a subprocess
+@support.requires_subprocess()
def run_python_until_end(*args, **env_vars):
env_required = interpreter_requires_environment()
cwd = env_vars.pop('__cwd', None)
return _PythonRunResult(rc, out, err), cmd_line
+@support.requires_subprocess()
def _assert_python(expected_success, /, *args, **env_vars):
res, cmd_line = run_python_until_end(*args, **env_vars)
if (res.rc and expected_success) or (not res.rc and not expected_success):
return _assert_python(False, *args, **env_vars)
+@support.requires_subprocess()
def spawn_python(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
"""Run a Python subprocess with the given arguments.
return zip_name, os.path.join(zip_name, script_name_in_zip)
+@support.requires_subprocess()
def run_test_script(script):
# use -u to try to get the full output if the test hangs or crash
if support.verbose:
class AuditTest(unittest.TestCase):
+
+ @support.requires_subprocess()
def do_test(self, *args):
with subprocess.Popen(
[sys.executable, "-Xutf8", AUDIT_TESTS_PY, *args],
if p.returncode:
self.fail("".join(p.stderr))
+ @support.requires_subprocess()
def run_python(self, *args):
events = []
with subprocess.Popen(
self.assertEqual(testfunction.attribute, "test")
self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test")
+ @support.requires_subprocess()
def test_no_FatalError_infinite_loop(self):
with support.SuppressCrashReport():
p = subprocess.Popen([sys.executable, "-c",
interpreter_requires_environment
)
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
# Debug build?
Py_DEBUG = hasattr(sys, "gettotalrefcount")
import tempfile
import textwrap
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
MS_WINDOWS = (os.name == 'nt')
MACOS = (sys.platform == 'darwin')
finally:
sys.stderr = orig_stderr
+ @support.requires_subprocess()
def test_disabled_by_default(self):
# By default, the module should be disabled
code = "import faulthandler; print(faulthandler.is_enabled())"
output = subprocess.check_output(args)
self.assertEqual(output.rstrip(), b"False")
+ @support.requires_subprocess()
def test_sys_xoptions(self):
# Test python -X faulthandler
code = "import faulthandler; print(faulthandler.is_enabled())"
output = subprocess.check_output(args, env=env)
self.assertEqual(output.rstrip(), b"True")
+ @support.requires_subprocess()
def test_env_var(self):
# empty env var
code = "import faulthandler; print(faulthandler.is_enabled())"
import sys
import time
import unittest
+from test import support
+
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
# Test import all of the things we're about to try testing up front.
import _io
import _pyio
-
@unittest.skipUnless(os.name == 'posix', 'tests requires a posix system.')
class TestFileIOSignalInterrupt:
def setUp(self):
import unittest
import unittest.mock
from test.support import (verbose, refcount_test,
- cpython_only)
+ cpython_only, requires_subprocess)
from test.support.import_helper import import_module
from test.support.os_helper import temp_dir, TESTFN, unlink
from test.support.script_helper import assert_python_ok, make_script
gc.collect() # this blows up (bad C pointer) when it fails
@cpython_only
+ @requires_subprocess()
def test_garbage_at_shutdown(self):
import subprocess
code = """if 1:
from subprocess import PIPE, Popen
from test.support import import_helper
from test.support import os_helper
-from test.support import _4G, bigmemtest
+from test.support import _4G, bigmemtest, requires_subprocess
from test.support.script_helper import assert_python_ok, assert_python_failure
gzip = import_helper.import_module('gzip')
class TestCommandLine(unittest.TestCase):
data = b'This is a simple test with gzip'
+ @requires_subprocess()
def test_decompress_stdin_stdout(self):
with io.BytesIO() as bytes_io:
with gzip.GzipFile(fileobj=bytes_io, mode='wb') as gzip_file:
self.assertEqual(rc, 1)
self.assertEqual(out, b'')
+ @requires_subprocess()
@create_and_remove_directory(TEMPDIR)
def test_compress_stdin_outfile(self):
args = sys.executable, '-m', 'gzip'
value_str = value.decode(sys.getfilesystemencoding(), 'surrogateescape')
self.assertEqual(os.environ['bytes'], value_str)
+ @support.requires_subprocess()
def test_putenv_unsetenv(self):
name = "PYTHONTESTVAR"
value = "testvalue"
self.assertRaises(OverflowError, os.setreuid, 0, self.UID_OVERFLOW)
@unittest.skipUnless(hasattr(os, 'setreuid'), 'test needs os.setreuid()')
+ @support.requires_subprocess()
def test_setreuid_neg1(self):
# Needs to accept -1. We run this in a subprocess to avoid
# altering the test runner's process state (issue8045).
'import os,sys;os.setreuid(-1,-1);sys.exit(0)'])
@unittest.skipUnless(hasattr(os, 'setregid'), 'test needs os.setregid()')
+ @support.requires_subprocess()
def test_setregid(self):
if os.getuid() != 0 and not HAVE_WHEEL_GROUP:
self.assertRaises(OSError, os.setregid, 0, 0)
self.assertRaises(OverflowError, os.setregid, 0, self.GID_OVERFLOW)
@unittest.skipUnless(hasattr(os, 'setregid'), 'test needs os.setregid()')
+ @support.requires_subprocess()
def test_setregid_neg1(self):
# Needs to accept -1. We run this in a subprocess to avoid
# altering the test runner's process state (issue8045).
self.fail("subprocess did not stop on {}".format(name))
@unittest.skip("subprocesses aren't inheriting Ctrl+C property")
+ @support.requires_subprocess()
def test_CTRL_C_EVENT(self):
from ctypes import wintypes
import ctypes
self._kill_with_event(signal.CTRL_C_EVENT, "CTRL_C_EVENT")
+ @support.requires_subprocess()
def test_CTRL_BREAK_EVENT(self):
self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
self.assertTrue(codecs.lookup(encoding))
+@support.requires_subprocess()
class PidTests(unittest.TestCase):
@unittest.skipUnless(hasattr(os, 'getppid'), "test needs os.getppid")
def test_getppid(self):
self.check_waitpid(code, exitcode=-signum, callback=kill_process)
+@support.requires_subprocess()
class SpawnTests(unittest.TestCase):
def create_args(self, *, with_env=False, use_bytes=False):
self.exitcode = 17
res = platform.architecture()
@os_helper.skip_unless_symlink
+ @support.requires_subprocess()
def test_architecture_via_symlink(self): # issue3762
with support.PythonSymlink() as py:
cmd = "-c", "import platform; print(platform.architecture())"
self.assertEqual(res[:5], expected[:5])
@unittest.skipIf(sys.platform in ['win32', 'OpenVMS'], "uname -p not used")
+ @support.requires_subprocess()
def test_uname_processor(self):
"""
On some systems, the processor must match the output
import threading
import time
import unittest
-from test.support import cpython_only
+from test.support import cpython_only, requires_subprocess
from test.support import threading_helper
from test.support.os_helper import TESTFN
# Another test case for poll(). This is copied from the test case for
# select(), modified to use poll() instead.
+ @requires_subprocess()
def test_poll2(self):
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
+@support.requires_subprocess()
class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected):
def tearDown(self):
os_helper.rmtree(self.directory)
+ @support.requires_subprocess()
def pycompilecmd(self, *args, **kwargs):
# assert_python_* helpers don't return proc object. We'll just use
# subprocess.run() instead of spawn_python() and its friends to test
import sys, io, subprocess
import quopri
+from test import support
ENCSAMPLE = b"""\
for p, e in self.HSTRINGS:
self.assertEqual(quopri.decodestring(e, header=True), p)
+ @support.requires_subprocess()
def test_scriptencode(self):
(p, e) = self.STRINGS[-1]
process = subprocess.Popen([sys.executable, "-mquopri"],
self.assertEqual(cout[i], e[i])
self.assertEqual(cout, e)
+ @support.requires_subprocess()
def test_scriptdecode(self):
(p, e) = self.STRINGS[-1]
process = subprocess.Popen([sys.executable, "-mquopri", "-d"],
from test.support import os_helper
from test.libregrtest import utils, setup
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
Py_DEBUG = hasattr(sys, 'gettotalrefcount')
ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..')
import unittest
import subprocess
from textwrap import dedent
-from test.support import cpython_only, SuppressCrashReport
+from test.support import cpython_only, has_subprocess_support, SuppressCrashReport
from test.support.script_helper import kill_python
+
+if not has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
+
+
def spawn_repl(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
"""Run the Python REPL with the given arguments.
import textwrap
import unittest
import warnings
-from test.support import no_tracing, verbose
+from test.support import no_tracing, verbose, requires_subprocess
from test.support.import_helper import forget, make_legacy_pyc, unload
from test.support.os_helper import create_empty_file, temp_dir
from test.support.script_helper import make_script, make_zip_script
)
super().run(*args, **kwargs)
+ @requires_subprocess()
def assertSigInt(self, *args, **kwargs):
proc = subprocess.run(*args, **kwargs, text=True, stderr=subprocess.PIPE)
self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n"))
self.assertLess(len(s), signal.NSIG)
@unittest.skipUnless(sys.executable, "sys.executable required.")
+ @support.requires_subprocess()
def test_keyboard_interrupt_exit_code(self):
"""KeyboardInterrupt triggers exit via SIGINT."""
process = subprocess.run(
signal.signal(7, handler)
@unittest.skipUnless(sys.executable, "sys.executable required.")
+ @support.requires_subprocess()
def test_keyboard_interrupt_exit_code(self):
"""KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
# We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
@unittest.skipUnless(hasattr(signal, 'siginterrupt'), "needs signal.siginterrupt()")
+@support.requires_subprocess()
class SiginterruptTest(unittest.TestCase):
def readpipe_interrupted(self, interrupt):
@unittest.skipUnless(site.ENABLE_USER_SITE, "requires access to PEP 370 "
"user-site (site.ENABLE_USER_SITE)")
+ @support.requires_subprocess()
def test_s_option(self):
# (ncoghlan) Change this to use script_helper...
usersite = site.USER_SITE
class StartupImportTests(unittest.TestCase):
+ @support.requires_subprocess()
def test_startup_imports(self):
# Get sys.path in isolated mode (python3 -I)
popen = subprocess.Popen([sys.executable, '-X', 'utf8', '-I',
}.difference(sys.builtin_module_names)
self.assertFalse(modules.intersection(collection_mods), stderr)
+ @support.requires_subprocess()
def test_startup_interactivehook(self):
r = subprocess.Popen([sys.executable, '-c',
'import sys; sys.exit(hasattr(sys, "__interactivehook__"))']).wait()
self.assertTrue(r, "'__interactivehook__' not added by site")
+ @support.requires_subprocess()
def test_startup_interactivehook_isolated(self):
# issue28192 readline is not automatically enabled in isolated mode
r = subprocess.Popen([sys.executable, '-I', '-c',
'import sys; sys.exit(hasattr(sys, "__interactivehook__"))']).wait()
self.assertFalse(r, "'__interactivehook__' added in isolated mode")
+ @support.requires_subprocess()
def test_startup_interactivehook_isolated_explicit(self):
# issue28192 readline can be explicitly enabled in isolated mode
r = subprocess.Popen([sys.executable, '-I', '-c',
sys_path.append(abs_path)
return sys_path
+ @support.requires_subprocess()
def test_underpth_basic(self):
libpath = test.support.STDLIB_DIR
exe_prefix = os.path.dirname(sys.executable)
"sys.path is incorrect"
)
+ @support.requires_subprocess()
def test_underpth_nosite_file(self):
libpath = test.support.STDLIB_DIR
exe_prefix = os.path.dirname(sys.executable)
"sys.path is incorrect"
)
+ @support.requires_subprocess()
def test_underpth_file(self):
libpath = test.support.STDLIB_DIR
exe_prefix = os.path.dirname(sys.executable)
)], env=env)
self.assertTrue(rc, "sys.path is incorrect")
+ @support.requires_subprocess()
def test_underpth_dll_file(self):
libpath = test.support.STDLIB_DIR
exe_prefix = os.path.dirname(sys.executable)
# -*- coding: koi8-r -*-
import unittest
-from test.support import script_helper, captured_stdout
+from test.support import script_helper, captured_stdout, requires_subprocess
from test.support.os_helper import TESTFN, unlink, rmtree
from test.support.import_helper import unload
import importlib
# two bytes in common with the UTF-8 BOM
self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20')
+ @requires_subprocess()
def test_20731(self):
sub = subprocess.Popen([sys.executable,
os.path.join(os.path.dirname(__file__),
if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test module requires subprocess")
+
mswindows = (sys.platform == "win32")
#
# pending child process
support.reap_children()
+ @support.requires_subprocess()
def check_options(self, args, func, expected=None):
code = f'from test.support import {func}; print(repr({func}()))'
cmd = [sys.executable, *args, '-c', code]
def test_clear_type_cache(self):
sys._clear_type_cache()
+ @support.requires_subprocess()
def test_ioencoding(self):
env = dict(os.environ)
'requires OS support of non-ASCII encodings')
@unittest.skipUnless(sys.getfilesystemencoding() == locale.getpreferredencoding(False),
'requires FS encoding to match locale')
+ @support.requires_subprocess()
def test_ioencoding_nonascii(self):
env = dict(os.environ)
@unittest.skipIf(sys.base_prefix != sys.prefix,
'Test is not venv-compatible')
+ @support.requires_subprocess()
def test_executable(self):
# sys.executable should be absolute
self.assertEqual(os.path.abspath(sys.executable), sys.executable)
'stdout: surrogateescape\n'
'stderr: backslashreplace\n')
+ @support.requires_subprocess()
def test_c_locale_surrogateescape(self):
self.check_locale_surrogateescape('C')
+ @support.requires_subprocess()
def test_posix_locale_surrogateescape(self):
self.check_locale_surrogateescape('POSIX')
self.assertIsInstance(level, int)
self.assertGreater(level, 0)
+ @support.requires_subprocess()
def test_sys_tracebacklimit(self):
code = """if 1:
import sys
out = out.decode('ascii', 'replace').rstrip()
self.assertEqual(out, 'mbcs replace')
+ @support.requires_subprocess()
def test_orig_argv(self):
code = textwrap.dedent('''
import sys
import shutil
from copy import copy
-from test.support import (captured_stdout, PythonSymlink)
+from test.support import (captured_stdout, PythonSymlink, requires_subprocess)
from test.support.import_helper import import_module
from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
change_cwd)
self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))
@skip_unless_symlink
+ @requires_subprocess()
def test_symlink(self): # Issue 7880
with PythonSymlink() as py:
cmd = "-c", "import sysconfig; print(sysconfig.get_platform())"
self.assertIn(ldflags, ldshared)
@unittest.skipUnless(sys.platform == "darwin", "test only relevant on MacOSX")
+ @requires_subprocess()
def test_platform_in_subprocess(self):
my_platform = sysconfig.get_platform()
"""
import test.support
-from test.support import threading_helper
+from test.support import threading_helper, requires_subprocess
from test.support import verbose, cpython_only, os_helper
from test.support.import_helper import import_module
from test.support.script_helper import assert_python_ok, assert_python_failure
lock = threading.Lock()
self.assertRaises(RuntimeError, lock.release)
+ @requires_subprocess()
def test_recursion_limit(self):
# Issue 9670
# test that excessive recursion within a non-main thread causes
import re
from test import support
from test.support import (Error, captured_output, cpython_only, ALWAYS_EQ,
- requires_debug_ranges, has_no_debug_ranges)
+ requires_debug_ranges, has_no_debug_ranges,
+ requires_subprocess)
from test.support.os_helper import TESTFN, unlink
from test.support.script_helper import assert_python_ok, assert_python_failure
str_name = '.'.join([X.__module__, X.__qualname__])
self.assertEqual(err[0], "%s: %s\n" % (str_name, str_value))
+ @requires_subprocess()
def test_encoded_file(self):
# Test that tracebacks are correctly printed for encoded source files:
# - correct line number (Issue2384)
@unittest.skipIf(MS_WINDOWS,
"os.device_encoding() doesn't implement "
"the UTF-8 Mode on Windows")
+ @support.requires_subprocess()
def test_device_encoding(self):
# Use stdout as TTY
if not sys.stdout.isatty():
import sys
import tempfile
from test.support import (captured_stdout, captured_stderr, requires_zlib,
- skip_if_broken_multiprocessing_synchronize, verbose)
+ skip_if_broken_multiprocessing_synchronize, verbose,
+ requires_subprocess)
from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree)
import unittest
import venv
or sys._base_executable != sys.executable,
'cannot run venv.create from within a venv on this platform')
+@requires_subprocess()
def check_output(cmd, encoding=None):
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
from test.support import import_helper
from test.support import os_helper
+if not support.has_subprocess_support:
+ raise unittest.SkipTest("test webserver requires subprocess")
URL = 'http://www.example.com'
CMD_NAME = 'test'
from test.support import script_helper
from test.support import (findfile, requires_zlib, requires_bz2,
- requires_lzma, captured_stdout)
+ requires_lzma, captured_stdout, requires_subprocess)
from test.support.os_helper import TESTFN, unlink, rmtree, temp_dir, temp_cwd
@unittest.skipUnless(sys.executable, 'sys.executable required.')
@unittest.skipUnless(os.access('/bin/bash', os.X_OK),
'Test relies on #!/bin/bash working.')
+ @requires_subprocess()
def test_execute_zip2(self):
output = subprocess.check_output([self.exe_zip, sys.executable])
self.assertIn(b'number in executable: 5', output)
@unittest.skipUnless(sys.executable, 'sys.executable required.')
@unittest.skipUnless(os.access('/bin/bash', os.X_OK),
'Test relies on #!/bin/bash working.')
+ @requires_subprocess()
def test_execute_zip64(self):
output = subprocess.check_output([self.exe_zip64, sys.executable])
self.assertIn(b'number in executable: 5', output)
--- /dev/null
+Add :func:`test.support.requires_subprocess` decorator to mark tests which
+require working :mod:`subprocess` module or ``os.spawn*``. The
+wasm32-emscripten platform has no support for processes.