2008-08-24 14:37:40 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""IPython Test Suite Runner.
|
2009-03-11 13:49:08 +08:00
|
|
|
|
2009-04-25 01:12:50 +08:00
|
|
|
This module provides a main entry point to a user script to test IPython
|
|
|
|
itself from the command line. There are two ways of running this script:
|
|
|
|
|
|
|
|
1. With the syntax `iptest all`. This runs our entire test suite by
|
2011-03-31 14:20:28 +08:00
|
|
|
calling this script (with different arguments) recursively. This
|
2009-04-25 01:12:50 +08:00
|
|
|
causes modules and package to be tested in different processes, using nose
|
|
|
|
or trial where appropriate.
|
|
|
|
2. With the regular nose syntax, like `iptest -vvs IPython`. In this form
|
|
|
|
the script simply calls nose, but with special command line flags and
|
|
|
|
plugins loaded.
|
|
|
|
|
2008-08-24 14:37:40 +08:00
|
|
|
"""
|
|
|
|
|
2009-03-11 13:49:08 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
update copyright to 2011/20xx-2011
Closes #1033 (rebased to prevent recursive merge). Closes #2.
459 *.py files in :
39 empty files
176 files without copyright
36 have copyright but don't cite the dev team
208 have copyright and cite the dev team
-----------------------------------------
0 not up to date (cite dev team but not right year)
FYI, list of files that don't have copyright (and are not empty..)
[
'IPython/config/profile/cluster/ipython_config.py',
'IPython/config/profile/math/ipython_config.py',
'IPython/config/profile/pylab/ipython_config.py',
'IPython/config/profile/pysh/ipython_config.py',
'IPython/config/profile/python3/ipython_config.py',
'IPython/config/profile/sympy/ipython_config.py',
'IPython/core/shadowns.py',
'IPython/core/tests/refbug.py',
'IPython/core/tests/simpleerr.py',
'IPython/core/tests/tclass.py',
'IPython/core/tests/test_application.py',
'IPython/core/tests/test_autocall.py',
'IPython/core/tests/test_completer.py',
'IPython/core/tests/test_fakemodule.py',
'IPython/core/tests/test_formatters.py',
'IPython/core/tests/test_handlers.py',
'IPython/core/tests/test_history.py',
'IPython/core/tests/test_imports.py',
'IPython/core/tests/test_iplib.py',
'IPython/core/tests/test_logger.py',
'IPython/core/tests/test_magic.py',
'IPython/core/tests/test_plugin.py',
'IPython/core/tests/test_prefilter.py',
'IPython/core/tests/test_profile.py',
'IPython/core/tests/test_run.py',
'IPython/core/tests/test_splitinput.py',
'IPython/deathrow/astyle.py',
'IPython/deathrow/dtutils.py',
'IPython/deathrow/Gnuplot2.py',
'IPython/deathrow/GnuplotInteractive.py',
'IPython/deathrow/GnuplotRuntime.py',
'IPython/deathrow/gui/wx/ipshell_nonblocking.py',
'IPython/deathrow/gui/wx/ipython_history.py',
'IPython/deathrow/gui/wx/thread_ex.py',
'IPython/deathrow/ibrowse.py',
'IPython/deathrow/igrid.py',
'IPython/deathrow/ipipe.py',
'IPython/deathrow/ipy_defaults.py',
'IPython/deathrow/ipy_kitcfg.py',
'IPython/deathrow/ipy_legacy.py',
'IPython/deathrow/ipy_p4.py',
'IPython/deathrow/ipy_profile_none.py',
'IPython/deathrow/ipy_profile_numpy.py',
'IPython/deathrow/ipy_profile_scipy.py',
'IPython/deathrow/ipy_profile_sh.py',
'IPython/deathrow/ipy_traits_completer.py',
'IPython/deathrow/ipy_vimserver.py',
'IPython/deathrow/numeric_formats.py',
'IPython/deathrow/oldfrontend/process/__init__.py',
'IPython/deathrow/oldfrontend/wx/ipythonx.py',
'IPython/deathrow/scitedirector.py',
'IPython/deathrow/tests/test_prefilter.py',
'IPython/deathrow/twshell.py',
'IPython/extensions/__init__.py',
'IPython/extensions/autoreload.py',
'IPython/extensions/storemagic.py',
'IPython/extensions/tests/test_autoreload.py',
'IPython/external/__init__.py',
'IPython/external/argparse/__init__.py',
'IPython/external/decorator/__init__.py',
'IPython/external/decorators/__init__.py',
'IPython/external/decorators/_decorators.py',
'IPython/external/decorators/_numpy_testing_noseclasses.py',
'IPython/external/decorators/_numpy_testing_utils.py',
'IPython/external/guid/__init__.py',
'IPython/external/Itpl/__init__.py',
'IPython/external/mglob/__init__.py',
'IPython/external/mglob/_mglob.py',
'IPython/external/path/__init__.py',
'IPython/external/path/_path.py',
'IPython/external/pexpect/__init__.py',
'IPython/external/pyparsing/__init__.py',
'IPython/external/qt.py',
'IPython/external/qt_for_kernel.py',
'IPython/external/simplegeneric/__init__.py',
'IPython/external/simplegeneric/_simplegeneric.py',
'IPython/frontend/html/notebook/__init__.py',
'IPython/frontend/html/notebook/tests/test_kernelsession.py',
'IPython/frontend/qt/base_frontend_mixin.py',
'IPython/frontend/qt/console/ansi_code_processor.py',
'IPython/frontend/qt/console/bracket_matcher.py',
'IPython/frontend/qt/console/call_tip_widget.py',
'IPython/frontend/qt/console/completion_lexer.py',
'IPython/frontend/qt/console/completion_widget.py',
'IPython/frontend/qt/console/console_widget.py',
'IPython/frontend/qt/console/history_console_widget.py',
'IPython/frontend/qt/console/ipython_widget.py',
'IPython/frontend/qt/console/kill_ring.py',
'IPython/frontend/qt/console/mainwindow.py',
'IPython/frontend/qt/console/pygments_highlighter.py',
'IPython/frontend/qt/console/qtconsoleapp.py',
'IPython/frontend/qt/console/rich_ipython_widget.py',
'IPython/frontend/qt/console/styles.py',
'IPython/frontend/qt/console/tests/test_ansi_code_processor.py',
'IPython/frontend/qt/console/tests/test_completion_lexer.py',
'IPython/frontend/qt/console/tests/test_kill_ring.py',
'IPython/frontend/qt/kernelmanager.py',
'IPython/frontend/qt/rich_text.py',
'IPython/frontend/qt/svg.py',
'IPython/frontend/qt/util.py',
'IPython/kernel/__init__.py',
'IPython/lib/clipboard.py',
'IPython/lib/display.py',
'IPython/lib/irunner.py',
'IPython/lib/security.py',
'IPython/lib/tests/test_imports.py',
'IPython/lib/tests/test_irunner.py',
'IPython/lib/tests/test_irunner_pylab_magic.py',
'IPython/lib/tests/test_security.py',
'IPython/nbformat/v1/tests/nbexamples.py',
'IPython/nbformat/v1/tests/test_json.py',
'IPython/nbformat/v1/tests/test_nbbase.py',
'IPython/nbformat/v2/tests/nbexamples.py',
'IPython/nbformat/v2/tests/test_json.py',
'IPython/nbformat/v2/tests/test_nbbase.py',
'IPython/nbformat/v2/tests/test_nbpy.py',
'IPython/quarantine/clearcmd.py',
'IPython/quarantine/envpersist.py',
'IPython/quarantine/ext_rescapture.py',
'IPython/quarantine/ipy_app_completers.py',
'IPython/quarantine/ipy_completers.py',
'IPython/quarantine/ipy_editors.py',
'IPython/quarantine/ipy_exportdb.py',
'IPython/quarantine/ipy_extutil.py',
'IPython/quarantine/ipy_fsops.py',
'IPython/quarantine/ipy_gnuglobal.py',
'IPython/quarantine/ipy_jot.py',
'IPython/quarantine/ipy_lookfor.py',
'IPython/quarantine/ipy_profile_doctest.py',
'IPython/quarantine/ipy_pydb.py',
'IPython/quarantine/ipy_rehashdir.py',
'IPython/quarantine/ipy_render.py',
'IPython/quarantine/ipy_server.py',
'IPython/quarantine/ipy_signals.py',
'IPython/quarantine/ipy_synchronize_with.py',
'IPython/quarantine/ipy_system_conf.py',
'IPython/quarantine/ipy_which.py',
'IPython/quarantine/ipy_winpdb.py',
'IPython/quarantine/ipy_workdir.py',
'IPython/quarantine/jobctrl.py',
'IPython/quarantine/ledit.py',
'IPython/quarantine/win32clip.py',
'IPython/testing/mkdoctests.py',
'IPython/testing/plugin/dtexample.py',
'IPython/testing/plugin/ipdoctest.py',
'IPython/testing/plugin/iptest.py',
'IPython/testing/plugin/setup.py',
'IPython/testing/plugin/show_refs.py',
'IPython/testing/plugin/simple.py',
'IPython/testing/plugin/simplevars.py',
'IPython/testing/plugin/test_ipdoctest.py',
'IPython/testing/plugin/test_refs.py',
'IPython/testing/skipdoctest.py',
'IPython/testing/tests/test_decorators.py',
'IPython/utils/autoattr.py',
'IPython/utils/nested_context.py',
'IPython/utils/pickleshare.py',
'IPython/utils/py3compat.py',
'IPython/utils/PyColorize.py',
'IPython/utils/rlineimpl.py',
'IPython/utils/strdispatch.py',
'IPython/utils/tempdir.py',
'IPython/utils/tests/test_imports.py',
'IPython/utils/tests/test_wildcard.py',
'IPython/utils/upgradedir.py',
'IPython/zmq/completer.py',
'IPython/zmq/displayhook.py',
'IPython/zmq/entry_point.py',
'IPython/zmq/frontend.py',
'IPython/zmq/iostream.py',
'IPython/zmq/ipkernel.py',
'IPython/zmq/log.py',
'IPython/zmq/parentpoller.py',
'IPython/zmq/pykernel.py',
'IPython/zmq/pylab/backend_inline.py',
'IPython/zmq/zmqshell.py'
]
2011-11-23 22:26:28 +08:00
|
|
|
# Copyright (C) 2009-2011 The IPython Development Team
|
2010-01-30 08:24:13 +08:00
|
|
|
#
|
|
|
|
# Distributed under the terms of the BSD License. The full license is in
|
|
|
|
# the file COPYING, distributed as part of this software.
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Imports
|
2009-03-11 13:49:08 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
2012-07-05 19:40:15 +08:00
|
|
|
from __future__ import print_function
|
2009-03-11 13:49:08 +08:00
|
|
|
|
2010-01-13 04:42:23 +08:00
|
|
|
# Stdlib
|
2012-06-11 09:05:52 +08:00
|
|
|
import glob
|
2009-04-25 01:12:50 +08:00
|
|
|
import os
|
|
|
|
import os.path as path
|
2010-01-08 08:47:46 +08:00
|
|
|
import signal
|
2008-08-24 14:37:40 +08:00
|
|
|
import sys
|
2009-04-25 01:12:50 +08:00
|
|
|
import subprocess
|
2009-08-02 08:08:32 +08:00
|
|
|
import tempfile
|
2009-04-25 01:12:50 +08:00
|
|
|
import time
|
2008-08-24 14:37:40 +08:00
|
|
|
import warnings
|
|
|
|
|
2010-01-13 04:42:23 +08:00
|
|
|
# Note: monkeypatch!
|
|
|
|
# We need to monkeypatch a small problem in nose itself first, before importing
|
|
|
|
# it for actual use. This should get into nose upstream, but its release cycle
|
|
|
|
# is slow and we need it for our parametric tests to work correctly.
|
2010-01-15 17:06:34 +08:00
|
|
|
from IPython.testing import nosepatch
|
2012-06-01 04:23:29 +08:00
|
|
|
|
|
|
|
# Monkeypatch extra assert methods into nose.tools if they're not already there.
|
|
|
|
# This can be dropped once we no longer test on Python 2.6
|
|
|
|
from IPython.testing import nose_assert_methods
|
|
|
|
|
2010-01-13 04:42:23 +08:00
|
|
|
# Now, proceed to import nose itself
|
2008-08-24 14:37:40 +08:00
|
|
|
import nose.plugins.builtin
|
2012-02-10 03:52:20 +08:00
|
|
|
from nose.plugins.xunit import Xunit
|
|
|
|
from nose import SkipTest
|
2009-03-11 13:49:08 +08:00
|
|
|
from nose.core import TestProgram
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2010-01-13 04:42:23 +08:00
|
|
|
# Our own imports
|
2012-06-28 04:04:54 +08:00
|
|
|
from IPython.utils import py3compat
|
2011-09-24 07:57:40 +08:00
|
|
|
from IPython.utils.importstring import import_item
|
2012-06-01 03:17:51 +08:00
|
|
|
from IPython.utils.path import get_ipython_module_path, get_ipython_package_dir
|
2013-07-03 06:00:28 +08:00
|
|
|
from IPython.utils.process import pycmd2argv
|
2010-01-30 08:24:13 +08:00
|
|
|
from IPython.utils.sysinfo import sys_info
|
2012-07-26 01:51:48 +08:00
|
|
|
from IPython.utils.tempdir import TemporaryDirectory
|
2012-06-01 02:56:06 +08:00
|
|
|
from IPython.utils.warn import warn
|
2010-01-30 08:24:13 +08:00
|
|
|
|
2010-01-15 17:06:34 +08:00
|
|
|
from IPython.testing import globalipapp
|
|
|
|
from IPython.testing.plugin.ipdoctest import IPythonDoctest
|
2012-02-10 03:52:20 +08:00
|
|
|
from IPython.external.decorators import KnownFailure, knownfailureif
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2009-04-26 00:04:56 +08:00
|
|
|
pjoin = path.join
|
|
|
|
|
2010-01-18 05:13:21 +08:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Globals
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Warnings control
|
|
|
|
#-----------------------------------------------------------------------------
|
2010-02-01 04:06:20 +08:00
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
# Twisted generates annoying warnings with Python 2.6, as will do other code
|
|
|
|
# that imports 'sets' as of today
|
|
|
|
warnings.filterwarnings('ignore', 'the sets module is deprecated',
|
|
|
|
DeprecationWarning )
|
|
|
|
|
2010-01-13 15:21:21 +08:00
|
|
|
# This one also comes from Twisted
|
|
|
|
warnings.filterwarnings('ignore', 'the sha module is deprecated',
|
|
|
|
DeprecationWarning)
|
|
|
|
|
2010-01-16 06:41:10 +08:00
|
|
|
# Wx on Fedora11 spits these out
|
|
|
|
warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch',
|
|
|
|
UserWarning)
|
|
|
|
|
2012-02-10 03:52:20 +08:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Monkeypatch Xunit to count known failures as skipped.
|
|
|
|
# ------------------------------------------------------------------------------
|
2012-02-10 04:20:19 +08:00
|
|
|
def monkeypatch_xunit():
|
2012-02-10 03:52:20 +08:00
|
|
|
try:
|
|
|
|
knownfailureif(True)(lambda: None)()
|
|
|
|
except Exception as e:
|
|
|
|
KnownFailureTest = type(e)
|
|
|
|
|
|
|
|
def addError(self, test, err, capt=None):
|
|
|
|
if issubclass(err[0], KnownFailureTest):
|
|
|
|
err = (SkipTest,) + err[1:]
|
|
|
|
return self.orig_addError(test, err, capt)
|
|
|
|
|
|
|
|
Xunit.orig_addError = Xunit.addError
|
|
|
|
Xunit.addError = addError
|
|
|
|
|
2009-03-11 13:49:08 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
2009-04-26 03:27:03 +08:00
|
|
|
# Logic for skipping doctests
|
2009-03-11 13:49:08 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
2011-09-24 07:57:40 +08:00
|
|
|
def extract_version(mod):
|
|
|
|
return mod.__version__
|
2009-03-11 13:49:08 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
def test_for(item, min_version=None, callback=extract_version):
|
|
|
|
"""Test to see if item is importable, and optionally check against a minimum
|
|
|
|
version.
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
If min_version is given, the default behavior is to check against the
|
|
|
|
`__version__` attribute of the item, but specifying `callback` allows you to
|
|
|
|
extract the value you are interested in. e.g::
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
In [1]: import sys
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
In [2]: from IPython.testing.iptest import test_for
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
|
|
|
|
Out[3]: True
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
"""
|
2009-04-26 03:27:03 +08:00
|
|
|
try:
|
2011-09-24 07:57:40 +08:00
|
|
|
check = import_item(item)
|
2010-01-17 06:50:08 +08:00
|
|
|
except (ImportError, RuntimeError):
|
2011-09-24 07:57:40 +08:00
|
|
|
# GTK reports Runtime error if it can't be initialized even if it's
|
2010-01-17 06:50:08 +08:00
|
|
|
# importable.
|
2009-04-26 03:27:03 +08:00
|
|
|
return False
|
|
|
|
else:
|
2011-02-28 13:06:02 +08:00
|
|
|
if min_version:
|
2011-09-24 07:57:40 +08:00
|
|
|
if callback:
|
|
|
|
# extra processing step to get version to compare
|
|
|
|
check = callback(check)
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-09-24 07:57:40 +08:00
|
|
|
return check >= min_version
|
2011-02-28 13:06:02 +08:00
|
|
|
else:
|
|
|
|
return True
|
2009-04-26 03:27:03 +08:00
|
|
|
|
2010-01-18 06:36:19 +08:00
|
|
|
# Global dict where we can store information on what we have and what we don't
|
|
|
|
# have available at test run time
|
|
|
|
have = {}
|
|
|
|
|
|
|
|
have['curses'] = test_for('_curses')
|
2011-04-11 15:22:11 +08:00
|
|
|
have['matplotlib'] = test_for('matplotlib')
|
2012-05-31 09:58:14 +08:00
|
|
|
have['numpy'] = test_for('numpy')
|
2011-09-24 07:57:40 +08:00
|
|
|
have['pexpect'] = test_for('IPython.external.pexpect')
|
2011-04-11 15:22:11 +08:00
|
|
|
have['pymongo'] = test_for('pymongo')
|
2012-05-23 05:38:59 +08:00
|
|
|
have['pygments'] = test_for('pygments')
|
2011-04-14 03:19:12 +08:00
|
|
|
have['qt'] = test_for('IPython.external.qt')
|
2012-05-31 09:58:14 +08:00
|
|
|
have['rpy2'] = test_for('rpy2')
|
2011-10-21 01:36:10 +08:00
|
|
|
have['sqlite3'] = test_for('sqlite3')
|
2012-05-31 13:01:34 +08:00
|
|
|
have['cython'] = test_for('Cython')
|
2012-06-08 05:18:42 +08:00
|
|
|
have['oct2py'] = test_for('oct2py')
|
2011-09-24 07:57:40 +08:00
|
|
|
have['tornado'] = test_for('tornado.version_info', (2,1,0), callback=None)
|
2012-12-19 05:13:02 +08:00
|
|
|
have['jinja2'] = test_for('jinja2')
|
2012-05-31 09:58:14 +08:00
|
|
|
have['wx'] = test_for('wx')
|
|
|
|
have['wx.aui'] = test_for('wx.aui')
|
2012-08-11 08:21:57 +08:00
|
|
|
have['azure'] = test_for('azure')
|
2013-07-01 07:06:22 +08:00
|
|
|
have['sphinx'] = test_for('sphinx')
|
|
|
|
have['markdown'] = test_for('markdown')
|
2011-09-24 07:57:40 +08:00
|
|
|
|
2013-01-26 04:37:49 +08:00
|
|
|
min_zmq = (2,1,11)
|
|
|
|
|
2013-01-29 06:37:09 +08:00
|
|
|
have['zmq'] = test_for('zmq.pyzmq_version_info', min_zmq, callback=lambda x: x())
|
2009-04-26 03:27:03 +08:00
|
|
|
|
2010-01-18 05:13:21 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Functions and classes
|
|
|
|
#-----------------------------------------------------------------------------
|
2009-04-26 01:05:09 +08:00
|
|
|
|
2010-01-18 06:36:19 +08:00
|
|
|
def report():
|
|
|
|
"""Return a string with a summary report of test-related variables."""
|
|
|
|
|
2010-10-27 14:16:59 +08:00
|
|
|
out = [ sys_info(), '\n']
|
2010-01-18 06:36:19 +08:00
|
|
|
|
|
|
|
avail = []
|
|
|
|
not_avail = []
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-18 06:36:19 +08:00
|
|
|
for k, is_avail in have.items():
|
|
|
|
if is_avail:
|
|
|
|
avail.append(k)
|
|
|
|
else:
|
|
|
|
not_avail.append(k)
|
|
|
|
|
|
|
|
if avail:
|
|
|
|
out.append('\nTools and libraries available at test time:\n')
|
|
|
|
avail.sort()
|
|
|
|
out.append(' ' + ' '.join(avail)+'\n')
|
|
|
|
|
|
|
|
if not_avail:
|
|
|
|
out.append('\nTools and libraries NOT available at test time:\n')
|
|
|
|
not_avail.sort()
|
|
|
|
out.append(' ' + ' '.join(not_avail)+'\n')
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-18 06:36:19 +08:00
|
|
|
return ''.join(out)
|
|
|
|
|
|
|
|
|
2009-07-28 06:38:27 +08:00
|
|
|
def make_exclude():
|
2010-01-13 09:36:00 +08:00
|
|
|
"""Make patterns of modules and packages to exclude from testing.
|
2010-02-01 04:06:20 +08:00
|
|
|
|
2010-01-13 09:36:00 +08:00
|
|
|
For the IPythonDoctest plugin, we need to exclude certain patterns that
|
|
|
|
cause testing problems. We should strive to minimize the number of
|
2010-02-01 04:06:20 +08:00
|
|
|
skipped modules, since this means untested code.
|
|
|
|
|
2010-01-13 09:36:00 +08:00
|
|
|
These modules and packages will NOT get scanned by nose at all for tests.
|
|
|
|
"""
|
|
|
|
# Simple utility to make IPython paths more readably, we need a lot of
|
|
|
|
# these below
|
|
|
|
ipjoin = lambda *paths: pjoin('IPython', *paths)
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-13 09:36:00 +08:00
|
|
|
exclusions = [ipjoin('external'),
|
|
|
|
ipjoin('quarantine'),
|
|
|
|
ipjoin('deathrow'),
|
2010-01-13 15:21:21 +08:00
|
|
|
# This guy is probably attic material
|
2010-01-13 09:36:00 +08:00
|
|
|
ipjoin('testing', 'mkdoctests'),
|
2010-01-13 15:21:21 +08:00
|
|
|
# Testing inputhook will need a lot of thought, to figure out
|
|
|
|
# how to have tests that don't lock up with the gui event
|
|
|
|
# loops in the picture
|
2010-01-13 09:36:00 +08:00
|
|
|
ipjoin('lib', 'inputhook'),
|
2010-01-10 09:55:56 +08:00
|
|
|
# Config files aren't really importable stand-alone
|
2010-01-13 09:36:00 +08:00
|
|
|
ipjoin('config', 'profile'),
|
2012-07-02 04:14:47 +08:00
|
|
|
# The notebook 'static' directory contains JS, css and other
|
|
|
|
# files for web serving. Occasionally projects may put a .py
|
|
|
|
# file in there (MathJax ships a conf.py), so we might as
|
|
|
|
# well play it safe and skip the whole thing.
|
2013-06-20 22:54:02 +08:00
|
|
|
ipjoin('html', 'static'),
|
|
|
|
ipjoin('html', 'fabfile'),
|
2010-01-10 09:55:56 +08:00
|
|
|
]
|
2011-10-21 01:36:10 +08:00
|
|
|
if not have['sqlite3']:
|
|
|
|
exclusions.append(ipjoin('core', 'tests', 'test_history'))
|
|
|
|
exclusions.append(ipjoin('core', 'history'))
|
2010-01-18 06:36:19 +08:00
|
|
|
if not have['wx']:
|
2010-01-13 09:36:00 +08:00
|
|
|
exclusions.append(ipjoin('lib', 'inputhookwx'))
|
2012-06-12 03:37:04 +08:00
|
|
|
|
2013-01-30 11:27:02 +08:00
|
|
|
if 'IPython.kernel.inprocess' not in sys.argv:
|
|
|
|
exclusions.append(ipjoin('kernel', 'inprocess'))
|
|
|
|
|
2012-06-12 03:37:04 +08:00
|
|
|
# FIXME: temporarily disable autoreload tests, as they can produce
|
|
|
|
# spurious failures in subsequent tests (cythonmagic).
|
|
|
|
exclusions.append(ipjoin('extensions', 'autoreload'))
|
|
|
|
exclusions.append(ipjoin('extensions', 'tests', 'test_autoreload'))
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-03-25 07:42:04 +08:00
|
|
|
# We do this unconditionally, so that the test suite doesn't import
|
|
|
|
# gtk, changing the default encoding and masking some unicode bugs.
|
|
|
|
exclusions.append(ipjoin('lib', 'inputhookgtk'))
|
2013-01-30 11:27:02 +08:00
|
|
|
exclusions.append(ipjoin('kernel', 'zmq', 'gui', 'gtkembed'))
|
2009-07-28 06:52:00 +08:00
|
|
|
|
2013-07-18 06:58:45 +08:00
|
|
|
# #Also done unconditionally, exclude nbconvert directories containing
|
|
|
|
# #config files used to test. Executing the config files with iptest would
|
|
|
|
# #cause an exception.
|
|
|
|
# exclusions.append(ipjoin('nbconvert', 'tests', 'files'))
|
|
|
|
# exclusions.append(ipjoin('nbconvert', 'exporters', 'tests', 'files'))
|
2013-07-18 06:40:30 +08:00
|
|
|
|
2009-07-28 06:38:27 +08:00
|
|
|
# These have to be skipped on win32 because the use echo, rm, cd, etc.
|
2011-05-30 06:10:48 +08:00
|
|
|
# See ticket https://github.com/ipython/ipython/issues/87
|
2009-07-28 06:38:27 +08:00
|
|
|
if sys.platform == 'win32':
|
2010-01-13 09:36:00 +08:00
|
|
|
exclusions.append(ipjoin('testing', 'plugin', 'test_exampleip'))
|
|
|
|
exclusions.append(ipjoin('testing', 'plugin', 'dtexample'))
|
2009-07-28 06:38:27 +08:00
|
|
|
|
2010-01-18 06:36:19 +08:00
|
|
|
if not have['pexpect']:
|
2012-06-30 16:00:56 +08:00
|
|
|
exclusions.extend([ipjoin('lib', 'irunner'),
|
2011-12-13 03:47:51 +08:00
|
|
|
ipjoin('lib', 'tests', 'test_irunner'),
|
2013-06-17 14:12:05 +08:00
|
|
|
ipjoin('terminal', 'console'),
|
2011-12-13 03:47:51 +08:00
|
|
|
])
|
2009-07-28 06:38:27 +08:00
|
|
|
|
2011-02-28 13:06:02 +08:00
|
|
|
if not have['zmq']:
|
2013-01-30 11:27:02 +08:00
|
|
|
exclusions.append(ipjoin('kernel'))
|
2013-06-17 14:12:05 +08:00
|
|
|
exclusions.append(ipjoin('qt'))
|
|
|
|
exclusions.append(ipjoin('html'))
|
|
|
|
exclusions.append(ipjoin('consoleapp.py'))
|
|
|
|
exclusions.append(ipjoin('terminal', 'console'))
|
2011-04-07 05:54:33 +08:00
|
|
|
exclusions.append(ipjoin('parallel'))
|
2012-05-23 05:38:59 +08:00
|
|
|
elif not have['qt'] or not have['pygments']:
|
2013-06-17 14:12:05 +08:00
|
|
|
exclusions.append(ipjoin('qt'))
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2011-04-08 08:50:07 +08:00
|
|
|
if not have['pymongo']:
|
|
|
|
exclusions.append(ipjoin('parallel', 'controller', 'mongodb'))
|
2011-05-05 08:06:30 +08:00
|
|
|
exclusions.append(ipjoin('parallel', 'tests', 'test_mongodb'))
|
2011-02-28 13:06:02 +08:00
|
|
|
|
2011-04-11 15:22:11 +08:00
|
|
|
if not have['matplotlib']:
|
2011-11-27 16:28:26 +08:00
|
|
|
exclusions.extend([ipjoin('core', 'pylabtools'),
|
2012-04-19 06:32:43 +08:00
|
|
|
ipjoin('core', 'tests', 'test_pylabtools'),
|
2013-01-30 11:27:02 +08:00
|
|
|
ipjoin('kernel', 'zmq', 'pylab'),
|
2012-04-19 06:32:43 +08:00
|
|
|
])
|
2011-04-11 15:22:11 +08:00
|
|
|
|
2012-05-31 13:01:34 +08:00
|
|
|
if not have['cython']:
|
|
|
|
exclusions.extend([ipjoin('extensions', 'cythonmagic')])
|
2012-06-01 01:06:13 +08:00
|
|
|
exclusions.extend([ipjoin('extensions', 'tests', 'test_cythonmagic')])
|
2012-05-31 13:01:34 +08:00
|
|
|
|
2012-06-08 05:18:42 +08:00
|
|
|
if not have['oct2py']:
|
|
|
|
exclusions.extend([ipjoin('extensions', 'octavemagic')])
|
|
|
|
exclusions.extend([ipjoin('extensions', 'tests', 'test_octavemagic')])
|
|
|
|
|
2011-08-31 00:39:57 +08:00
|
|
|
if not have['tornado']:
|
2013-06-17 14:12:05 +08:00
|
|
|
exclusions.append(ipjoin('html'))
|
2011-08-31 00:39:57 +08:00
|
|
|
|
2012-12-19 05:13:02 +08:00
|
|
|
if not have['jinja2']:
|
2013-06-20 22:54:02 +08:00
|
|
|
exclusions.append(ipjoin('html', 'notebookapp'))
|
2012-12-19 05:13:02 +08:00
|
|
|
|
2012-05-31 09:58:14 +08:00
|
|
|
if not have['rpy2'] or not have['numpy']:
|
|
|
|
exclusions.append(ipjoin('extensions', 'rmagic'))
|
|
|
|
exclusions.append(ipjoin('extensions', 'tests', 'test_rmagic'))
|
|
|
|
|
2012-08-11 08:21:57 +08:00
|
|
|
if not have['azure']:
|
2013-06-20 22:54:02 +08:00
|
|
|
exclusions.append(ipjoin('html', 'services', 'notebooks', 'azurenbmanager'))
|
2012-08-11 08:21:57 +08:00
|
|
|
|
2013-07-01 07:06:22 +08:00
|
|
|
if not all((have['pygments'], have['jinja2'], have['markdown'], have['sphinx'])):
|
|
|
|
exclusions.append(ipjoin('nbconvert'))
|
|
|
|
|
2009-07-28 06:38:27 +08:00
|
|
|
# This is needed for the reg-exp to match on win32 in the ipdoctest plugin.
|
|
|
|
if sys.platform == 'win32':
|
2010-01-10 08:30:59 +08:00
|
|
|
exclusions = [s.replace('\\','\\\\') for s in exclusions]
|
2012-06-01 02:56:06 +08:00
|
|
|
|
|
|
|
# check for any exclusions that don't seem to exist:
|
2012-06-01 03:17:51 +08:00
|
|
|
parent, _ = os.path.split(get_ipython_package_dir())
|
2012-06-01 02:56:06 +08:00
|
|
|
for exclusion in exclusions:
|
2012-06-12 05:21:18 +08:00
|
|
|
if exclusion.endswith(('deathrow', 'quarantine')):
|
|
|
|
# ignore deathrow/quarantine, which exist in dev, but not install
|
|
|
|
continue
|
2012-06-01 03:17:51 +08:00
|
|
|
fullpath = pjoin(parent, exclusion)
|
2012-06-11 09:05:52 +08:00
|
|
|
if not os.path.exists(fullpath) and not glob.glob(fullpath + '.*'):
|
2012-08-14 21:15:30 +08:00
|
|
|
warn("Excluding nonexistent file: %r" % exclusion)
|
2009-07-28 06:38:27 +08:00
|
|
|
|
2010-01-10 08:30:59 +08:00
|
|
|
return exclusions
|
2009-04-26 01:05:09 +08:00
|
|
|
|
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
class IPTester(object):
|
|
|
|
"""Call that calls iptest or trial in a subprocess.
|
|
|
|
"""
|
2010-01-08 08:47:46 +08:00
|
|
|
#: string, name of test runner that will be called
|
|
|
|
runner = None
|
|
|
|
#: list, parameters for test runner
|
|
|
|
params = None
|
|
|
|
#: list, arguments of system call to be made to call test runner
|
|
|
|
call_args = None
|
2012-07-26 06:04:54 +08:00
|
|
|
#: list, subprocesses we start (for cleanup)
|
|
|
|
processes = None
|
2012-01-26 06:25:44 +08:00
|
|
|
#: str, coverage xml output file
|
|
|
|
coverage_xml = None
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-15 17:06:34 +08:00
|
|
|
def __init__(self, runner='iptest', params=None):
|
2010-01-08 08:47:46 +08:00
|
|
|
"""Create new test runner."""
|
2010-01-18 05:13:21 +08:00
|
|
|
p = os.path
|
2010-01-08 08:04:08 +08:00
|
|
|
if runner == 'iptest':
|
2013-06-29 22:36:28 +08:00
|
|
|
iptest_app = os.path.abspath(get_ipython_module_path('IPython.testing.iptest'))
|
2010-01-31 11:43:46 +08:00
|
|
|
self.runner = pycmd2argv(iptest_app) + sys.argv[1:]
|
2010-02-01 04:06:20 +08:00
|
|
|
else:
|
|
|
|
raise Exception('Not a valid test runner: %s' % repr(runner))
|
2010-01-08 08:04:08 +08:00
|
|
|
if params is None:
|
|
|
|
params = []
|
2010-01-15 17:06:34 +08:00
|
|
|
if isinstance(params, str):
|
2010-01-08 08:04:08 +08:00
|
|
|
params = [params]
|
|
|
|
self.params = params
|
|
|
|
|
|
|
|
# Assemble call
|
|
|
|
self.call_args = self.runner+self.params
|
2012-01-25 05:23:58 +08:00
|
|
|
|
2012-01-27 19:16:35 +08:00
|
|
|
# Find the section we're testing (IPython.foo)
|
|
|
|
for sect in self.params:
|
2013-06-30 05:29:51 +08:00
|
|
|
if sect.startswith('IPython') or sect in special_test_suites: break
|
2012-01-27 19:16:35 +08:00
|
|
|
else:
|
|
|
|
raise ValueError("Section not found", self.params)
|
|
|
|
|
2012-01-25 05:23:58 +08:00
|
|
|
if '--with-xunit' in self.call_args:
|
2012-06-29 02:23:13 +08:00
|
|
|
|
|
|
|
self.call_args.append('--xunit-file')
|
|
|
|
# FIXME: when Windows uses subprocess.call, these extra quotes are unnecessary:
|
|
|
|
xunit_file = path.abspath(sect+'.xunit.xml')
|
|
|
|
if sys.platform == 'win32':
|
|
|
|
xunit_file = '"%s"' % xunit_file
|
|
|
|
self.call_args.append(xunit_file)
|
2012-01-26 06:25:44 +08:00
|
|
|
|
2012-01-27 03:01:43 +08:00
|
|
|
if '--with-xml-coverage' in self.call_args:
|
2012-01-26 06:25:44 +08:00
|
|
|
self.coverage_xml = path.abspath(sect+".coverage.xml")
|
2012-01-27 03:01:43 +08:00
|
|
|
self.call_args.remove('--with-xml-coverage')
|
2012-01-26 06:29:03 +08:00
|
|
|
self.call_args = ["coverage", "run", "--source="+sect] + self.call_args[1:]
|
2010-01-08 08:04:08 +08:00
|
|
|
|
2012-07-26 06:04:54 +08:00
|
|
|
# Store anything we start to clean up on deletion
|
|
|
|
self.processes = []
|
2010-01-08 08:47:46 +08:00
|
|
|
|
2012-07-17 08:29:02 +08:00
|
|
|
def _run_cmd(self):
|
2012-07-26 01:51:48 +08:00
|
|
|
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
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
def run(self):
|
|
|
|
"""Run the stored commands"""
|
|
|
|
try:
|
2012-01-26 06:25:44 +08:00
|
|
|
retcode = self._run_cmd()
|
2012-09-28 06:58:00 +08:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
return -signal.SIGINT
|
2010-01-08 08:04:08 +08:00
|
|
|
except:
|
|
|
|
import traceback
|
|
|
|
traceback.print_exc()
|
|
|
|
return 1 # signal failure
|
2012-01-26 06:25:44 +08:00
|
|
|
|
|
|
|
if self.coverage_xml:
|
2012-01-27 03:03:00 +08:00
|
|
|
subprocess.call(["coverage", "xml", "-o", self.coverage_xml])
|
2012-01-26 06:25:44 +08:00
|
|
|
return retcode
|
2010-01-08 08:04:08 +08:00
|
|
|
|
2010-01-08 08:47:46 +08:00
|
|
|
def __del__(self):
|
|
|
|
"""Cleanup on exit by killing any leftover processes."""
|
2012-07-26 06:04:54 +08:00
|
|
|
for subp in self.processes:
|
2012-07-26 08:41:53 +08:00
|
|
|
if subp.poll() is not None:
|
|
|
|
continue # process is already dead
|
|
|
|
|
2010-01-08 08:47:46 +08:00
|
|
|
try:
|
2012-09-28 06:58:00 +08:00
|
|
|
print('Cleaning up stale PID: %d' % subp.pid)
|
2012-07-26 06:04:54 +08:00
|
|
|
subp.kill()
|
|
|
|
except: # (OSError, WindowsError) ?
|
2010-01-08 08:47:46 +08:00
|
|
|
# This is just a best effort, if we fail or the process was
|
|
|
|
# really gone, ignore it.
|
2011-10-04 22:14:41 +08:00
|
|
|
pass
|
2012-09-28 06:58:00 +08:00
|
|
|
else:
|
|
|
|
for i in range(10):
|
|
|
|
if subp.poll() is None:
|
|
|
|
time.sleep(0.1)
|
|
|
|
else:
|
|
|
|
break
|
2010-01-08 09:39:24 +08:00
|
|
|
|
2012-07-26 08:41:53 +08:00
|
|
|
if subp.poll() is None:
|
|
|
|
# The process did not die...
|
2012-09-28 06:58:00 +08:00
|
|
|
print('... failed. Manual cleanup may be required.')
|
2010-01-08 08:04:08 +08:00
|
|
|
|
2013-06-30 05:29:51 +08:00
|
|
|
|
|
|
|
special_test_suites = {
|
|
|
|
'autoreload': ['IPython.extensions.autoreload', 'IPython.extensions.tests.test_autoreload'],
|
|
|
|
}
|
2013-06-17 14:12:05 +08:00
|
|
|
|
2012-08-03 04:42:48 +08:00
|
|
|
def make_runners(inc_slow=False):
|
2010-01-08 08:04:08 +08:00
|
|
|
"""Define the top-level packages that need to be tested.
|
|
|
|
"""
|
|
|
|
|
2010-01-16 06:41:10 +08:00
|
|
|
# Packages to be tested via nose, that only depend on the stdlib
|
2013-06-17 14:12:05 +08:00
|
|
|
nose_pkg_names = ['config', 'core', 'extensions', 'lib', 'terminal',
|
2013-07-01 07:06:22 +08:00
|
|
|
'testing', 'utils', 'nbformat']
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2013-06-17 14:12:05 +08:00
|
|
|
if have['qt']:
|
|
|
|
nose_pkg_names.append('qt')
|
|
|
|
|
|
|
|
if have['tornado']:
|
|
|
|
nose_pkg_names.append('html')
|
|
|
|
|
2011-04-07 12:34:12 +08:00
|
|
|
if have['zmq']:
|
2013-01-30 11:27:02 +08:00
|
|
|
nose_pkg_names.append('kernel')
|
|
|
|
nose_pkg_names.append('kernel.inprocess')
|
2012-08-03 04:42:48 +08:00
|
|
|
if inc_slow:
|
|
|
|
nose_pkg_names.append('parallel')
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2013-07-01 07:06:22 +08:00
|
|
|
if all((have['pygments'], have['jinja2'], have['markdown'], have['sphinx'])):
|
|
|
|
nose_pkg_names.append('nbconvert')
|
|
|
|
|
2010-01-16 06:41:10 +08:00
|
|
|
# For debugging this code, only load quick stuff
|
2010-01-18 05:13:21 +08:00
|
|
|
#nose_pkg_names = ['core', 'extensions'] # dbg
|
2010-01-16 06:41:10 +08:00
|
|
|
|
|
|
|
# Make fully qualified package names prepending 'IPython.' to our name lists
|
|
|
|
nose_packages = ['IPython.%s' % m for m in nose_pkg_names ]
|
|
|
|
|
|
|
|
# Make runners
|
|
|
|
runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ]
|
2013-06-30 05:29:51 +08:00
|
|
|
|
|
|
|
for name in special_test_suites:
|
|
|
|
runners.append((name, IPTester('iptest', params=name)))
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
return runners
|
|
|
|
|
|
|
|
|
2009-04-25 01:12:50 +08:00
|
|
|
def run_iptest():
|
|
|
|
"""Run the IPython test suite using nose.
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2009-04-25 01:12:50 +08:00
|
|
|
This function is called when this script is **not** called with the form
|
|
|
|
`iptest all`. It simply calls nose with appropriate command line flags
|
|
|
|
and accepts all of the standard nose arguments.
|
2008-08-24 14:37:40 +08:00
|
|
|
"""
|
2012-02-10 04:20:19 +08:00
|
|
|
# Apply our monkeypatch to Xunit
|
2012-02-14 07:17:05 +08:00
|
|
|
if '--with-xunit' in sys.argv and not hasattr(Xunit, 'orig_addError'):
|
2012-02-10 04:20:19 +08:00
|
|
|
monkeypatch_xunit()
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2011-10-04 22:14:41 +08:00
|
|
|
warnings.filterwarnings('ignore',
|
2008-08-24 14:37:40 +08:00
|
|
|
'This will be removed soon. Use IPython.testing.util instead')
|
2013-06-30 05:29:51 +08:00
|
|
|
|
|
|
|
if sys.argv[1] in special_test_suites:
|
|
|
|
sys.argv[1:2] = special_test_suites[sys.argv[1]]
|
|
|
|
special_suite = True
|
|
|
|
else:
|
|
|
|
special_suite = False
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2010-01-17 06:43:41 +08:00
|
|
|
argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2010-01-10 08:30:59 +08:00
|
|
|
'--with-ipdoctest',
|
|
|
|
'--ipdoctest-tests','--ipdoctest-extension=txt',
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2008-11-09 13:54:34 +08:00
|
|
|
# We add --exe because of setuptools' imbecility (it
|
|
|
|
# blindly does chmod +x on ALL files). Nose does the
|
|
|
|
# right thing and it tries to avoid executables,
|
|
|
|
# setuptools unfortunately forces our hand here. This
|
|
|
|
# has been discussed on the distutils list and the
|
|
|
|
# setuptools devs refuse to fix this problem!
|
|
|
|
'--exe',
|
|
|
|
]
|
2012-08-11 13:14:53 +08:00
|
|
|
if '-a' not in argv and '-A' not in argv:
|
|
|
|
argv = argv + ['-a', '!crash']
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2010-01-18 05:13:21 +08:00
|
|
|
if nose.__version__ >= '0.11':
|
|
|
|
# I don't fully understand why we need this one, but depending on what
|
|
|
|
# directory the test suite is run from, if we don't give it, 0 tests
|
|
|
|
# get run. Specifically, if the test suite is run from the source dir
|
|
|
|
# with an argument (like 'iptest.py IPython.core', 0 tests are run,
|
|
|
|
# even if the same call done in this directory works fine). It appears
|
|
|
|
# that if the requested package is in the current dir, nose bails early
|
|
|
|
# by default. Since it's otherwise harmless, leave it in by default
|
|
|
|
# for nose >= 0.11, though unfortunately nose 0.10 doesn't support it.
|
|
|
|
argv.append('--traverse-namespace')
|
2008-08-24 14:37:40 +08:00
|
|
|
|
2011-08-07 10:54:42 +08:00
|
|
|
# use our plugin for doctesting. It will remove the standard doctest plugin
|
|
|
|
# if it finds it enabled
|
2013-06-30 05:29:51 +08:00
|
|
|
ipdt = IPythonDoctest() if special_suite else IPythonDoctest(make_exclude())
|
|
|
|
plugins = [ipdt, KnownFailure()]
|
2012-09-27 07:23:54 +08:00
|
|
|
|
|
|
|
# We need a global ipython running in this process, but the special
|
|
|
|
# in-process group spawns its own IPython kernels, so for *that* group we
|
|
|
|
# must avoid also opening the global one (otherwise there's a conflict of
|
|
|
|
# singletons). Ultimately the solution to this problem is to refactor our
|
|
|
|
# assumptions about what needs to be a singleton and what doesn't (app
|
|
|
|
# objects should, individual shells shouldn't). But for now, this
|
|
|
|
# workaround allows the test suite for the inprocess module to complete.
|
2013-01-30 11:27:02 +08:00
|
|
|
if not 'IPython.kernel.inprocess' in sys.argv:
|
2012-09-27 07:23:54 +08:00
|
|
|
globalipapp.start_ipython()
|
|
|
|
|
2010-01-10 08:30:59 +08:00
|
|
|
# Now nose can run
|
2011-08-07 10:54:42 +08:00
|
|
|
TestProgram(argv=argv, addplugins=plugins)
|
2009-04-25 01:12:50 +08:00
|
|
|
|
|
|
|
|
2012-08-03 04:42:48 +08:00
|
|
|
def run_iptestall(inc_slow=False):
|
2009-04-25 01:12:50 +08:00
|
|
|
"""Run the entire IPython test suite by calling nose and trial.
|
2011-10-04 22:14:41 +08:00
|
|
|
|
2009-04-25 01:12:50 +08:00
|
|
|
This function constructs :class:`IPTester` instances for all IPython
|
|
|
|
modules and package and then runs each of them. This causes the modules
|
|
|
|
and packages of IPython to be tested each in their own subprocess using
|
2012-04-10 02:01:21 +08:00
|
|
|
nose.
|
2012-08-03 04:42:48 +08:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
|
|
|
|
inc_slow : bool, optional
|
|
|
|
Include slow tests, like IPython.parallel. By default, these tests aren't
|
|
|
|
run.
|
2009-04-25 01:12:50 +08:00
|
|
|
"""
|
2009-07-28 06:38:27 +08:00
|
|
|
|
2012-08-03 04:42:48 +08:00
|
|
|
runners = make_runners(inc_slow=inc_slow)
|
2009-07-28 06:38:27 +08:00
|
|
|
|
2010-01-08 08:04:08 +08:00
|
|
|
# Run the test runners in a temporary dir so we can nuke it when finished
|
|
|
|
# to clean up any junk files left over by accident. This also makes it
|
|
|
|
# robust against being run in non-writeable directories by mistake, as the
|
|
|
|
# temp dir will always be user-writeable.
|
2011-07-13 01:19:38 +08:00
|
|
|
curdir = os.getcwdu()
|
2010-01-08 08:04:08 +08:00
|
|
|
testdir = tempfile.gettempdir()
|
|
|
|
os.chdir(testdir)
|
|
|
|
|
2009-04-25 01:12:50 +08:00
|
|
|
# Run all test runners, tracking execution time
|
2010-01-15 17:06:34 +08:00
|
|
|
failed = []
|
2009-04-25 01:12:50 +08:00
|
|
|
t_start = time.time()
|
2010-01-08 08:04:08 +08:00
|
|
|
try:
|
2010-01-15 17:06:34 +08:00
|
|
|
for (name, runner) in runners:
|
2012-07-05 19:40:15 +08:00
|
|
|
print('*'*70)
|
|
|
|
print('IPython test group:',name)
|
2010-01-08 08:04:08 +08:00
|
|
|
res = runner.run()
|
|
|
|
if res:
|
2010-01-15 17:06:34 +08:00
|
|
|
failed.append( (name, runner) )
|
2012-09-28 06:58:00 +08:00
|
|
|
if res == -signal.SIGINT:
|
|
|
|
print("Interrupted")
|
|
|
|
break
|
2010-01-08 08:04:08 +08:00
|
|
|
finally:
|
|
|
|
os.chdir(curdir)
|
2009-04-25 01:12:50 +08:00
|
|
|
t_end = time.time()
|
|
|
|
t_tests = t_end - t_start
|
|
|
|
nrunners = len(runners)
|
|
|
|
nfail = len(failed)
|
|
|
|
# summarize results
|
2012-07-05 19:40:15 +08:00
|
|
|
print()
|
|
|
|
print('*'*70)
|
|
|
|
print('Test suite completed for system with the following information:')
|
|
|
|
print(report())
|
|
|
|
print('Ran %s test groups in %.3fs' % (nrunners, t_tests))
|
|
|
|
print()
|
|
|
|
print('Status:')
|
2009-04-25 01:12:50 +08:00
|
|
|
if not failed:
|
2012-07-05 19:40:15 +08:00
|
|
|
print('OK')
|
2009-04-25 01:12:50 +08:00
|
|
|
else:
|
|
|
|
# If anything went wrong, point out what command to rerun manually to
|
|
|
|
# see the actual errors and individual summary
|
2012-07-05 19:40:15 +08:00
|
|
|
print('ERROR - %s out of %s test groups failed.' % (nfail, nrunners))
|
2010-01-15 17:06:34 +08:00
|
|
|
for name, failed_runner in failed:
|
2012-07-05 19:40:15 +08:00
|
|
|
print('-'*40)
|
|
|
|
print('Runner failed:',name)
|
|
|
|
print('You may wish to rerun this one individually, with:')
|
2012-06-28 04:04:54 +08:00
|
|
|
failed_call_args = [py3compat.cast_unicode(x) for x in failed_runner.call_args]
|
2012-07-05 19:40:15 +08:00
|
|
|
print(u' '.join(failed_call_args))
|
|
|
|
print()
|
2011-05-25 02:21:45 +08:00
|
|
|
# Ensure that our exit code indicates failure
|
|
|
|
sys.exit(1)
|
2009-04-25 01:12:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2010-01-15 17:06:34 +08:00
|
|
|
for arg in sys.argv[1:]:
|
2013-06-30 05:29:51 +08:00
|
|
|
if arg.startswith('IPython') or arg in special_test_suites:
|
2010-01-15 18:00:11 +08:00
|
|
|
# This is in-process
|
2009-04-26 07:09:59 +08:00
|
|
|
run_iptest()
|
2010-01-15 17:06:34 +08:00
|
|
|
else:
|
2012-08-03 04:42:48 +08:00
|
|
|
if "--all" in sys.argv:
|
|
|
|
sys.argv.remove("--all")
|
|
|
|
inc_slow = True
|
|
|
|
else:
|
|
|
|
inc_slow = False
|
2010-01-15 18:00:11 +08:00
|
|
|
# This starts subprocesses
|
2012-08-03 04:42:48 +08:00
|
|
|
run_iptestall(inc_slow=inc_slow)
|
2009-04-25 01:12:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2009-07-29 17:13:26 +08:00
|
|
|
main()
|