From 3449d30c6dcc5882e10b30d29915109e0d1d5cd1 2010-01-31 03:43:46 From: Brian Granger Date: 2010-01-31 03:43:46 Subject: [PATCH] Removed the top-level iptest.py and INSTALLED logic. Fernando's branch introduced the ability to run the test suite from a top-level iptest.py script. This allowed IPython to be tested without installation. The implementation was fragile and we also decided that we *want* people to install IPython as part of testing it, so we removed this feature. --- diff --git a/IPython/core/ipapp.py b/IPython/core/ipapp.py index ea0bba4..213afa3 100755 --- a/IPython/core/ipapp.py +++ b/IPython/core/ipapp.py @@ -649,3 +649,6 @@ def launch_new_instance(): app = IPythonApp() app.start() + +if __name__ == '__main__': + launch_new_instance() diff --git a/IPython/kernel/error.py b/IPython/kernel/error.py index b5f6d24..2d0533e 100644 --- a/IPython/kernel/error.py +++ b/IPython/kernel/error.py @@ -17,6 +17,7 @@ __test__ = {} #------------------------------------------------------------------------------- # Imports #------------------------------------------------------------------------------- + from IPython.kernel.core import error #------------------------------------------------------------------------------- @@ -203,5 +204,4 @@ def collect_exceptions(rlist, method): raise CompositeError(msg, elist) except CompositeError, e: raise e - diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 1558b60..28e2b22 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -70,12 +70,6 @@ pjoin = path.join # Globals #----------------------------------------------------------------------------- -# By default, we assume IPython has been installed. But if the test suite is -# being run from a source tree that has NOT been installed yet, this flag can -# be set to False by the entry point scripts, to let us know that we must call -# the source tree versions of the scripts which manipulate sys.path instead of -# assuming that things exist system-wide. -INSTALLED = True #----------------------------------------------------------------------------- # Warnings control @@ -132,8 +126,6 @@ def report(): out = [ sys_info() ] - out.append('\nRunning from an installed IPython: %s\n' % INSTALLED) - avail = [] not_avail = [] @@ -255,17 +247,8 @@ class IPTester(object): """Create new test runner.""" p = os.path if runner == 'iptest': - if INSTALLED: - iptest_app = get_ipython_module_path('IPython.testing.iptest') - self.runner = pycmd2argv(iptest_app) + sys.argv[1:] - else: - # Find our own 'iptest' script OS-level entry point. Don't - # look system-wide, so we are sure we pick up *this one*. And - # pass through to subprocess call our own sys.argv - ippath = p.abspath(p.join(p.dirname(__file__),'..','..')) - script = p.join(ippath, 'iptest.py') - self.runner = pycmd2argv(script) + sys.argv[1:] - + iptest_app = get_ipython_module_path('IPython.testing.iptest') + self.runner = pycmd2argv(iptest_app) + sys.argv[1:] else: # For trial, it needs to be installed system-wide self.runner = pycmd2argv(p.abspath(find_cmd('trial'))) diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index 8c62ec6..a6dc9da 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -52,13 +52,6 @@ from . import decorators as dec # Globals #----------------------------------------------------------------------------- -# By default, we assume IPython has been installed. But if the test suite is -# being run from a source tree that has NOT been installed yet, this flag can -# be set to False by the entry point scripts, to let us know that we must call -# the source tree versions of the scripts which manipulate sys.path instead of -# assuming that things exist system-wide. -INSTALLED = True - # Make a bunch of nose.tools assert wrappers that can be used in test # generators. This will expose an assert* function for each one in nose.tools. @@ -207,17 +200,9 @@ 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 - p = os.path - if INSTALLED: - ipython_cmd = find_cmd('ipython') - else: - ippath = p.abspath(p.join(p.dirname(__file__),'..','..')) - ipython_script = p.join(ippath, 'ipython.py') - ipython_cmd = 'python "%s"' % ipython_script + ipython_cmd = find_cmd('ipython') # Absolute path for filename - full_fname = p.join(test_dir, fname) + full_fname = os.path.join(test_dir, fname) full_cmd = '%s %s %s' % (ipython_cmd, cmdargs, full_fname) #print >> sys.stderr, 'FULL CMD:', full_cmd # dbg return getoutputerror(full_cmd) diff --git a/iptest.py b/iptest.py deleted file mode 100755 index a9935f6..0000000 --- a/iptest.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python -"""Test script for IPython. - -The actual ipython test script to be installed with 'python setup.py install' -is in './scripts' directory, and will test IPython from an importable -location. - -This file is here (ipython source root directory) to facilitate non-root -'zero-installation testing and development' (just copy the source tree -somewhere and run iptest.py). - -You can run this script directly, type -h to see all options.""" - -# Ensure that the imported IPython packages come from *THIS* IPython, not some -# other one that may exist system-wide -import os, sys -this_dir = os.path.dirname(os.path.abspath(__file__)) -sys.path.insert(0, this_dir) - -import IPython.testing.tools as t -import IPython.testing.iptest as ipt -t.INSTALLED = False -ipt.INSTALLED = False - -# Now proceed with execution -execfile(os.path.join(this_dir, 'IPython', 'scripts', 'iptest'))