From d277b37c6a0c13cffd34c6a4ac6492d7f9df13b4 2010-01-12 22:12:25 From: Fernando Perez Date: 2010-01-12 22:12:25 Subject: [PATCH] Various fixes for IPython.core tests to pass under win32. --- diff --git a/IPython/core/tests/test_run.py b/IPython/core/tests/test_run.py index a6b07fe..250ca04 100644 --- a/IPython/core/tests/test_run.py +++ b/IPython/core/tests/test_run.py @@ -141,7 +141,12 @@ class TestMagicRunSimple(tt.TempFileMixin): _ip.magic('run "%s"' % self.fname) _ip.runlines('t = isinstance(f(), foo)') nt.assert_true(_ip.user_ns['t']) - + + # We have to skip these in win32 because genutils.getoutputerr() crashes, + # due to the fact that subprocess does not support close_fds when + # redirecting stdout/err. So unless someone who knows more tells us how to + # implement genutils.getoutputerr() in win32, we're stuck avoiding these. + @dec.skip_win32 def test_obj_del(self): """Test that object's __del__ methods are called on exit.""" @@ -154,6 +159,7 @@ class TestMagicRunSimple(tt.TempFileMixin): self.mktmp(src) tt.ipexec_validate(self.fname, 'object A deleted') + @dec.skip_win32 def test_tclass(self): mydir = os.path.dirname(__file__) tc = os.path.join(mydir, 'tclass') diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index 49c0126..d382fb9 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -174,7 +174,7 @@ def default_argv(): ipcdir = os.path.dirname(default.__file__) ipconf = os.path.join(ipcdir,'ipython_config.py') return ['--colors=NoColor', '--no-term-title','--no-banner', - '--config-file=%s' % ipconf, '--autocall=0', + '--config-file="%s"' % ipconf, '--autocall=0', '--prompt-out=""'] @@ -203,9 +203,14 @@ def ipexec(fname, options=None): _ip = get_ipython() test_dir = os.path.dirname(__file__) + # Find the ipython script from the package we're using, so that the test + # suite can be run from the source tree without an installed IPython + ipython_package_dir = genutils.get_ipython_package_dir() + ipython_script = os.path.join(ipython_package_dir,'scripts','ipython') + ipython_cmd = 'python "%s"' % ipython_script + # Absolute path for filename full_fname = os.path.join(test_dir, fname) - ipython_cmd = platutils.find_cmd('ipython') - full_cmd = '%s %s %s' % (ipython_cmd, cmdargs, full_fname) + full_cmd = '%s %s "%s"' % (ipython_cmd, cmdargs, full_fname) return genutils.getoutputerror(full_cmd) @@ -256,11 +261,14 @@ class TempFileMixin(object): self.fname = fname def teardown(self): - self.tmpfile.close() - try: - os.unlink(self.fname) - except: - # On Windows, even though we close the file, we still can't delete - # it. I have no clue why - pass + if hasattr(self, 'tmpfile'): + # If the tmpfile wasn't made because of skipped tests, like in + # win32, there's nothing to cleanup. + self.tmpfile.close() + try: + os.unlink(self.fname) + except: + # On Windows, even though we close the file, we still can't + # delete it. I have no clue why + pass