summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-22 17:25:44 (GMT)
committerGitHub <noreply@github.com>2018-06-22 17:25:44 (GMT)
commit8fbbdf0c3107c3052659e166f73990b466eacbb0 (patch)
tree81ce7da212017b7918b2373dc68a50cb9fda52fc /Lib/test/test_subprocess.py
parent209abf746985526bce255e2fba97d3246924885d (diff)
downloadcpython-8fbbdf0c3107c3052659e166f73990b466eacbb0.zip
cpython-8fbbdf0c3107c3052659e166f73990b466eacbb0.tar.gz
cpython-8fbbdf0c3107c3052659e166f73990b466eacbb0.tar.bz2
bpo-33671: Add support.MS_WINDOWS and support.MACOS (GH-7800)
* Add support.MS_WINDOWS: True if Python is running on Microsoft Windows. * Add support.MACOS: True if Python is running on Apple macOS. * Replace support.is_android with support.ANDROID * Replace support.is_jython with support.JYTHON * Cleanup code to initialize unix_shell
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 4b089f5..569e3e0 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -35,13 +35,11 @@ except ImportError:
if support.PGO:
raise unittest.SkipTest("test is not helpful for PGO")
-mswindows = (sys.platform == "win32")
-
#
# Depends on the following external programs: Python
#
-if mswindows:
+if support.MS_WINDOWS:
SETBINARY = ('import msvcrt; msvcrt.setmode(sys.stdout.fileno(), '
'os.O_BINARY);')
else:
@@ -314,7 +312,7 @@ class ProcessTestCase(BaseTestCase):
self._assert_python, pre_args,
executable=NONEXISTING_CMD[0])
- @unittest.skipIf(mswindows, "executable argument replaces shell")
+ @unittest.skipIf(support.MS_WINDOWS, "executable argument replaces shell")
def test_executable_replaces_shell(self):
# Check that the executable argument replaces the default shell
# when shell=True.
@@ -363,7 +361,7 @@ class ProcessTestCase(BaseTestCase):
temp_dir = self._normalize_cwd(temp_dir)
self._assert_cwd(temp_dir, sys.executable, cwd=FakePath(temp_dir))
- @unittest.skipIf(mswindows, "pending resolution of issue #15533")
+ @unittest.skipIf(support.MS_WINDOWS, "pending resolution of issue #15533")
def test_cwd_with_relative_arg(self):
# Check that Popen looks for args[0] relative to cwd if args[0]
# is relative.
@@ -379,7 +377,7 @@ class ProcessTestCase(BaseTestCase):
python_dir = self._normalize_cwd(python_dir)
self._assert_cwd(python_dir, rel_python, cwd=python_dir)
- @unittest.skipIf(mswindows, "pending resolution of issue #15533")
+ @unittest.skipIf(support.MS_WINDOWS, "pending resolution of issue #15533")
def test_cwd_with_relative_executable(self):
# Check that Popen looks for executable relative to cwd if executable
# is relative (and that executable takes precedence over args[0]).
@@ -1008,7 +1006,7 @@ class ProcessTestCase(BaseTestCase):
def test_no_leaking(self):
# Make sure we leak no resources
- if not mswindows:
+ if not support.MS_WINDOWS:
max_handles = 1026 # too much for most UNIX systems
else:
max_handles = 2050 # too much for (at least some) Windows setups
@@ -1244,7 +1242,7 @@ class ProcessTestCase(BaseTestCase):
t = threading.Timer(0.2, kill_proc_timer_thread)
t.start()
- if mswindows:
+ if support.MS_WINDOWS:
expected_errorcode = 1
else:
# Should be -9 because of the proc.kill() from the thread.
@@ -1365,13 +1363,13 @@ class ProcessTestCase(BaseTestCase):
fds_after_exception = os.listdir(fd_directory)
self.assertEqual(fds_before_popen, fds_after_exception)
- @unittest.skipIf(mswindows, "behavior currently not supported on Windows")
+ @unittest.skipIf(support.MS_WINDOWS, "behavior currently not supported on Windows")
def test_file_not_found_includes_filename(self):
with self.assertRaises(FileNotFoundError) as c:
subprocess.call(['/opt/nonexistent_binary', 'with', 'some', 'args'])
self.assertEqual(c.exception.filename, '/opt/nonexistent_binary')
- @unittest.skipIf(mswindows, "behavior currently not supported on Windows")
+ @unittest.skipIf(support.MS_WINDOWS, "behavior currently not supported on Windows")
def test_file_not_found_with_bad_cwd(self):
with self.assertRaises(FileNotFoundError) as c:
subprocess.Popen(['exit', '0'], cwd='/some/nonexistent/directory')
@@ -1505,7 +1503,7 @@ class RunFuncTestCase(BaseTestCase):
self.assertIn('capture_output', c.exception.args[0])
-@unittest.skipIf(mswindows, "POSIX specific tests")
+@unittest.skipIf(support.MS_WINDOWS, "POSIX specific tests")
class POSIXProcessTestCase(BaseTestCase):
def setUp(self):
@@ -2788,7 +2786,7 @@ class POSIXProcessTestCase(BaseTestCase):
self.assertEqual(returncode, -3)
-@unittest.skipUnless(mswindows, "Windows specific tests")
+@unittest.skipUnless(support.MS_WINDOWS, "Windows specific tests")
class Win32ProcessTestCase(BaseTestCase):
def test_startupinfo(self):
@@ -3093,7 +3091,7 @@ class MiscTests(unittest.TestCase):
dir = tempfile.mkdtemp()
name = os.path.join(dir, "foo")
status, output = subprocess.getstatusoutput(
- ("type " if mswindows else "cat ") + name)
+ ("type " if support.MS_WINDOWS else "cat ") + name)
self.assertNotEqual(status, 0)
finally:
if dir is not None:
@@ -3127,7 +3125,7 @@ class ProcessTestCaseNoPoll(ProcessTestCase):
ProcessTestCase.tearDown(self)
-@unittest.skipUnless(mswindows, "Windows-specific tests")
+@unittest.skipUnless(support.MS_WINDOWS, "Windows-specific tests")
class CommandsWithSpaces (BaseTestCase):
def setUp(self):