From 653c12fb77a51adf398df6971e3a5cafbd004ecf 2013-07-15 19:23:21 From: MinRK Date: 2013-07-15 19:23:21 Subject: [PATCH] Python 2.6 doesn't support `python -m IPython` add workarounds to testing.tools and test_console --- diff --git a/IPython/terminal/console/tests/test_console.py b/IPython/terminal/console/tests/test_console.py index 98f510e..553478a 100644 --- a/IPython/terminal/console/tests/test_console.py +++ b/IPython/terminal/console/tests/test_console.py @@ -20,7 +20,6 @@ from nose import SkipTest from IPython.testing import decorators as dec from IPython.utils import py3compat -from IPython.utils.process import find_cmd #----------------------------------------------------------------------------- # Test functions begin @@ -31,7 +30,19 @@ def test_console_starts(): """test that `ipython console` starts a terminal""" from IPython.external import pexpect - p = pexpect.spawn(sys.executable, args=['-m', 'IPython', 'console', '--colors=NoColor']) + args = ['console', '--colors=NoColor'] + # FIXME: remove workaround for 2.6 support + if sys.version_info[:2] > (2,6): + args = ['-m', 'IPython'] + args + cmd = sys.executable + else: + cmd = 'ipython' + + try: + p = pexpect.spawn(cmd, args=args) + except IOError: + raise SkipTest("Couldn't find command %s" % cmd) + idx = p.expect([r'In \[\d+\]', pexpect.EOF], timeout=15) nt.assert_equal(idx, 0, "expected in prompt") p.sendline('5') diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index ad40bc6..200e4f9 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -188,7 +188,11 @@ def ipexec(fname, options=None): _ip = get_ipython() test_dir = os.path.dirname(__file__) - ipython_cmd = pipes.quote(sys.executable) + " -m IPython" + # FIXME: remove workaround for 2.6 support + if sys.version_info[:2] > (2,6): + ipython_cmd = pipes.quote(sys.executable) + " -m IPython" + else: + ipython_cmd = "ipython" # Absolute path for filename full_fname = os.path.join(test_dir, fname) full_cmd = '%s %s %s' % (ipython_cmd, cmdargs, full_fname)