summaryrefslogtreecommitdiff
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-02-10 21:40:33 +0000
committerEzio Melotti <ezio.melotti@gmail.com>2010-02-10 21:40:33 +0000
commit8f6a28702961430a2217be64d9d53e2ea490f1b3 (patch)
tree8f12bbfb76770371bc068d2a3541ac4b136aa7c1 /Lib/test/test_subprocess.py
parent1c3abf475e9213ebc127aa089c43793c14f281b5 (diff)
downloadcpython-git-8f6a28702961430a2217be64d9d53e2ea490f1b3.tar.gz
#7712: add a temp_cwd context manager to test_support and use it in regrtest to run all the tests in a temporary directory, saving the original CWD in test_support.SAVEDCWD. Thanks to Florent Xicluna who helped with the patch.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index db93393777..cef4300aff 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -7,6 +7,7 @@ import os
import tempfile
import time
import re
+import sysconfig
mswindows = (sys.platform == "win32")
@@ -140,9 +141,21 @@ class ProcessTestCase(unittest.TestCase):
p.wait()
self.assertEqual(p.stderr, None)
- def test_executable(self):
- p = subprocess.Popen(["somethingyoudonthave",
- "-c", "import sys; sys.exit(47)"],
+ def test_executable_with_cwd(self):
+ python_dir = os.path.dirname(os.path.realpath(sys.executable))
+ p = subprocess.Popen(["somethingyoudonthave", "-c",
+ "import sys; sys.exit(47)"],
+ executable=sys.executable, cwd=python_dir)
+ p.wait()
+ self.assertEqual(p.returncode, 47)
+
+ @unittest.skipIf(sysconfig.is_python_build(),
+ "need an installed Python. See #7774")
+ def test_executable_without_cwd(self):
+ # For a normal installation, it should work without 'cwd'
+ # argument. For test runs in the build directory, see #7774.
+ p = subprocess.Popen(["somethingyoudonthave", "-c",
+ "import sys; sys.exit(47)"],
executable=sys.executable)
p.wait()
self.assertEqual(p.returncode, 47)