Merged revisions 78136 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78136 | ezio.melotti | 2010-02-10 23:40:33 +0200 (Wed, 10 Feb 2010) | 1 line

  #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.
........
This commit is contained in:
Ezio Melotti 2010-02-18 09:37:05 +00:00
parent a3211ee8d4
commit 184bdfb03a
4 changed files with 98 additions and 27 deletions

View file

@ -7,6 +7,7 @@ import os
import tempfile
import time
import re
import sysconfig
mswindows = (sys.platform == "win32")
@ -141,10 +142,21 @@ class ProcessTestCase(unittest.TestCase):
p.wait()
self.assertEqual(p.stderr, None)
def test_executable(self):
arg0 = os.path.join(os.path.dirname(sys.executable),
"somethingyoudonthave")
p = subprocess.Popen([arg0, "-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)