Permalink
Browse files

Create a unique & temporary IPYTHONDIR for each testing group.

  • Loading branch information...
1 parent b2fc42b commit 0b4fd4cf4bdce1a4b9db43f6f91a0c5d73ec2140 @bfroehle committed Jul 25, 2012
Showing with 13 additions and 9 deletions.
  1. +13 −9 IPython/testing/iptest.py
View
@@ -59,6 +59,7 @@
from IPython.utils.path import get_ipython_module_path, get_ipython_package_dir
from IPython.utils.process import find_cmd, pycmd2argv
from IPython.utils.sysinfo import sys_info
+from IPython.utils.tempdir import TemporaryDirectory
from IPython.utils.warn import warn
from IPython.testing import globalipapp
@@ -374,15 +375,18 @@ def __init__(self, runner='iptest', params=None):
self.processes = []
def _run_cmd(self):
- # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg
- subp = subprocess.Popen(self.call_args)
- self.processes.append(subp)
- # If this fails, the process will be left in self.processes and cleaned
- # up later, but if the wait call succeeds, then we can clear the
- # stored process.
- retcode = subp.wait()
- self.processes.pop()
- return retcode
+ with TemporaryDirectory() as IPYTHONDIR:
+ env = os.environ.copy()
+ env['IPYTHONDIR'] = IPYTHONDIR
+ # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg
+ subp = subprocess.Popen(self.call_args, env=env)
+ self.processes.append(subp)
+ # If this fails, the process will be left in self.processes and
+ # cleaned up later, but if the wait call succeeds, then we can
+ # clear the stored process.
+ retcode = subp.wait()
+ self.processes.pop()
+ return retcode
def run(self):
"""Run the stored commands"""

0 comments on commit 0b4fd4c

Please sign in to comment.