From 0af7025d912f150c3cf540cbaf3e506fba0a837d 2009-08-02 00:08:32 From: Fernando Perez Date: 2009-08-02 00:08:32 Subject: [PATCH] Make iptest more reliable under Win32. This ensures the trial part of the tests runs in win32. --- diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 5ea906f..0f347d2 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -24,6 +24,7 @@ import os import os.path as path import sys import subprocess +import tempfile import time import warnings @@ -190,9 +191,29 @@ class IPTester(object): # Assemble call self.call_args = self.runner+self.params - def run(self): - """Run the stored commands""" - return subprocess.call(self.call_args) + if sys.platform == 'win32': + def run(self): + """Run the stored commands""" + # On Windows, cd to temporary directory to run tests. Otherwise, + # Twisted's trial may not be able to execute 'trial IPython', since + # it will confuse the IPython module name with the ipython + # execution scripts, because the windows file system isn't case + # sensitive. + # We also use os.system instead of subprocess.call, because I was + # having problems with subprocess and I just don't know enough + # about win32 to debug this reliably. Os.system may be the 'old + # fashioned' way to do it, but it works just fine. If someone + # later can clean this up that's fine, as long as the tests run + # reliably in win32. + curdir = os.getcwd() + os.chdir(tempfile.gettempdir()) + stat = os.system(' '.join(self.call_args)) + os.chdir(curdir) + return stat + else: + def run(self): + """Run the stored commands""" + return subprocess.call(self.call_args) def make_runners():