##// END OF EJS Templates
Don't use fork to start the notebook in js tests...
Don't use fork to start the notebook in js tests It can encounter a weird segfault on OS X with sqlite when Qt is present (?!) The main reason to use the fork was to get the port number, but this is easy now that notebooks write a server-info file. Further advantage is that the symptom of a failed server start is no longer silence and hanging tests, but an actual failure with the server's log output.

File last commit:

r15317:92e068ab
r15909:ea201ca5
Show More
iptest.py
524 lines | 18.1 KiB | text/x-python | PythonLexer
Fernando Perez
Add module I forgot
r1574 # -*- coding: utf-8 -*-
"""IPython Test Suite Runner.
Fernando Perez
Cleanup testing machinery.
r1851
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972 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
Brian Granger
Removed Twisted related things from setup scripts and testing.
r3486 calling this script (with different arguments) recursively. This
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972 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.
Fernando Perez
Add module I forgot
r1574 """
Fernando Perez
Cleanup testing machinery.
r1851 #-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2009-2011 The IPython Development Team
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
Fernando Perez
Cleanup testing machinery.
r1851 #-----------------------------------------------------------------------------
Matthias BUSSONNIER
use print function in module with `print >>`
r7817 from __future__ import print_function
Fernando Perez
Cleanup testing machinery.
r1851
Fernando Perez
Remove accidentally introduced runtime nose dependencies.
r2442 # Stdlib
MinRK
use glob for bad exclusion warning...
r7412 import glob
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 from io import BytesIO
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972 import os
import os.path as path
Fernando Perez
Add module I forgot
r1574 import sys
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 from threading import Thread, Lock, Event
Fernando Perez
Add module I forgot
r1574 import warnings
Fernando Perez
Remove accidentally introduced runtime nose dependencies.
r2442 # Now, proceed to import nose itself
Fernando Perez
Add module I forgot
r1574 import nose.plugins.builtin
Thomas Kluyver
Monkeypatch Xunit to count known failures as skips, not errors.
r6101 from nose.plugins.xunit import Xunit
from nose import SkipTest
Fernando Perez
Cleanup testing machinery.
r1851 from nose.core import TestProgram
Thomas Kluyver
Start refactoring test machinery
r12608 from nose.plugins import Plugin
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 from nose.util import safe_str
Fernando Perez
Add module I forgot
r1574
Fernando Perez
Remove accidentally introduced runtime nose dependencies.
r2442 # Our own imports
Paul Ivanov
added javascript section with casperjs requirement
r13263 from IPython.utils.process import is_cmd_found
MinRK
allow more processing in test_for...
r4857 from IPython.utils.importstring import import_item
Fernando Perez
Let iptest pass arguments correctly to nose (in-process or in subprocess)....
r2480 from IPython.testing.plugin.ipdoctest import IPythonDoctest
Thomas Kluyver
Monkeypatch Xunit to count known failures as skips, not errors.
r6101 from IPython.external.decorators import KnownFailure, knownfailureif
Fernando Perez
Add module I forgot
r1574
Brian Granger
Making the doctest exclude paths os independent.
r1979 pjoin = path.join
Fernando Perez
Robustness fixes in test suite machinery....
r2494
#-----------------------------------------------------------------------------
# Globals
#-----------------------------------------------------------------------------
Fernando Perez
Cleanup testing machinery.
r1851 #-----------------------------------------------------------------------------
Fernando Perez
Work in multiple places to improve state of the test suite....
r2398 # Warnings control
#-----------------------------------------------------------------------------
Brian Granger
Minor cleanup in iptest.py and growl.py.
r2512
Fernando Perez
Work in multiple places to improve state of the test suite....
r2398 # 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 )
Fernando Perez
Fixes for test suite in win32 when all dependencies (esp. Twisted) are...
r2461 # This one also comes from Twisted
warnings.filterwarnings('ignore', 'the sha module is deprecated',
DeprecationWarning)
Fernando Perez
Fixes to make test suite more robust on Fedora....
r2483 # Wx on Fedora11 spits these out
warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch',
UserWarning)
Thomas Kluyver
Monkeypatch Xunit to count known failures as skips, not errors.
r6101 # ------------------------------------------------------------------------------
# Monkeypatch Xunit to count known failures as skipped.
# ------------------------------------------------------------------------------
Thomas Kluyver
Make separate function to monkeypatch Xunit.
r6102 def monkeypatch_xunit():
Thomas Kluyver
Monkeypatch Xunit to count known failures as skips, not errors.
r6101 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
Fernando Perez
Work in multiple places to improve state of the test suite....
r2398 #-----------------------------------------------------------------------------
Thomas Kluyver
Start refactoring test machinery
r12608 # Check which dependencies are installed and greater than minimum version.
Fernando Perez
Cleanup testing machinery.
r1851 #-----------------------------------------------------------------------------
MinRK
allow more processing in test_for...
r4857 def extract_version(mod):
return mod.__version__
Fernando Perez
Cleanup testing machinery.
r1851
MinRK
allow more processing in test_for...
r4857 def test_for(item, min_version=None, callback=extract_version):
"""Test to see if item is importable, and optionally check against a minimum
version.
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 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::
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 In [1]: import sys
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 In [2]: from IPython.testing.iptest import test_for
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
Out[3]: True
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 """
Administrator
Fixing bugs with the testing system.
r1981 try:
MinRK
allow more processing in test_for...
r4857 check = import_item(item)
Fernando Perez
Make the test suite runnable without X11 connections....
r2488 except (ImportError, RuntimeError):
MinRK
allow more processing in test_for...
r4857 # GTK reports Runtime error if it can't be initialized even if it's
Fernando Perez
Make the test suite runnable without X11 connections....
r2488 # importable.
Administrator
Fixing bugs with the testing system.
r1981 return False
else:
MinRK
add zmq checking in iptest
r3640 if min_version:
MinRK
allow more processing in test_for...
r4857 if callback:
# extra processing step to get version to compare
check = callback(check)
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
allow more processing in test_for...
r4857 return check >= min_version
MinRK
add zmq checking in iptest
r3640 else:
return True
Administrator
Fixing bugs with the testing system.
r1981
Fernando Perez
Added diagnostics printout at the end of the test suite....
r2496 # 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')
Fernando Perez
Do not generate output for empty figures in Qt console....
r3731 have['matplotlib'] = test_for('matplotlib')
Fernando Perez
Ensure that no tests are attempted if numpy or rpy2 are not present....
r7224 have['numpy'] = test_for('numpy')
MinRK
allow more processing in test_for...
r4857 have['pexpect'] = test_for('IPython.external.pexpect')
Fernando Perez
Do not generate output for empty figures in Qt console....
r3731 have['pymongo'] = test_for('pymongo')
MinRK
test for pygments before running qt tests
r6874 have['pygments'] = test_for('pygments')
MinRK
update test exclusions...
r3761 have['qt'] = test_for('IPython.external.qt')
Fernando Perez
Ensure that no tests are attempted if numpy or rpy2 are not present....
r7224 have['rpy2'] = test_for('rpy2')
MinRK
Allow IPython to run without sqlite3...
r5147 have['sqlite3'] = test_for('sqlite3')
Brian Granger
More code review changes:...
r7102 have['cython'] = test_for('Cython')
Stefan van der Walt
Skip octavemagic tests if oct2py is unavailable.
r7385 have['oct2py'] = test_for('oct2py')
MinRK
update test requirements for IPython.html
r13177 have['tornado'] = test_for('tornado.version_info', (3,1,0), callback=None)
Bradley M. Froehle
Skip notebookapp testing if jinja2 is not available.
r8908 have['jinja2'] = test_for('jinja2')
MinRK
update test requirements for IPython.html
r13177 have['requests'] = test_for('requests')
Brian E. Granger
Fixing test logic for nbconvert to get tests to pass.
r11095 have['sphinx'] = test_for('sphinx')
Paul Ivanov
added javascript section with casperjs requirement
r13263 have['casperjs'] = is_cmd_found('casperjs')
MinRK
allow more processing in test_for...
r4857
MinRK
bump minimum pyzmq version to 2.1.11...
r9336 min_zmq = (2,1,11)
MinRK
fix callback testing for pyzmq version_info
r9339 have['zmq'] = test_for('zmq.pyzmq_version_info', min_zmq, callback=lambda x: x())
Administrator
Fixing bugs with the testing system.
r1981
Fernando Perez
Robustness fixes in test suite machinery....
r2494 #-----------------------------------------------------------------------------
Thomas Kluyver
Start refactoring test machinery
r12608 # Test suite definitions
Fernando Perez
Robustness fixes in test suite machinery....
r2494 #-----------------------------------------------------------------------------
Administrator
Fixing doctest EXCLUDES in iptest on win32....
r1980
Thomas Kluyver
Start refactoring test machinery
r12608 test_group_names = ['parallel', 'kernel', 'kernel.inprocess', 'config', 'core',
'extensions', 'lib', 'terminal', 'testing', 'utils',
Thomas Kluyver
Separate out machinery for running JS tests
r13279 'nbformat', 'qt', 'html', 'nbconvert'
Thomas Kluyver
Start refactoring test machinery
r12608 ]
class TestSection(object):
def __init__(self, name, includes):
self.name = name
self.includes = includes
self.excludes = []
self.dependencies = []
self.enabled = True
def exclude(self, module):
if not module.startswith('IPython'):
module = self.includes[0] + "." + module
self.excludes.append(module.replace('.', os.sep))
def requires(self, *packages):
self.dependencies.extend(packages)
@property
def will_run(self):
return self.enabled and all(have[p] for p in self.dependencies)
# Name -> (include, exclude, dependencies_met)
test_sections = {n:TestSection(n, ['IPython.%s' % n]) for n in test_group_names}
# Exclusions and dependencies
# ---------------------------
# core:
sec = test_sections['core']
if not have['sqlite3']:
sec.exclude('tests.test_history')
sec.exclude('history')
if not have['matplotlib']:
sec.exclude('pylabtools'),
sec.exclude('tests.test_pylabtools')
# lib:
sec = test_sections['lib']
if not have['zmq']:
sec.exclude('kernel')
# We do this unconditionally, so that the test suite doesn't import
# gtk, changing the default encoding and masking some unicode bugs.
sec.exclude('inputhookgtk')
Thomas Kluyver
Don't check for wx in the test suite....
r13757 # We also do this unconditionally, because wx can interfere with Unix signals.
# There are currently no tests for it anyway.
sec.exclude('inputhookwx')
Thomas Kluyver
Start refactoring test machinery
r12608 # 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
sec.exclude('inputhook')
# testing:
Thomas Kluyver
Fix excludes for IPython.testing
r12777 sec = test_sections['testing']
# These have to be skipped on win32 because they use echo, rm, cd, etc.
Thomas Kluyver
Start refactoring test machinery
r12608 # See ticket https://github.com/ipython/ipython/issues/87
if sys.platform == 'win32':
sec.exclude('plugin.test_exampleip')
sec.exclude('plugin.dtexample')
# terminal:
if (not have['pexpect']) or (not have['zmq']):
test_sections['terminal'].exclude('console')
# parallel
sec = test_sections['parallel']
sec.requires('zmq')
if not have['pymongo']:
sec.exclude('controller.mongodb')
sec.exclude('tests.test_mongodb')
# kernel:
sec = test_sections['kernel']
sec.requires('zmq')
# The in-process kernel tests are done in a separate section
sec.exclude('inprocess')
# importing gtk sets the default encoding, which we want to avoid
sec.exclude('zmq.gui.gtkembed')
if not have['matplotlib']:
sec.exclude('zmq.pylab')
# kernel.inprocess:
test_sections['kernel.inprocess'].requires('zmq')
# extensions:
sec = test_sections['extensions']
if not have['cython']:
sec.exclude('cythonmagic')
sec.exclude('tests.test_cythonmagic')
if not have['oct2py']:
sec.exclude('octavemagic')
sec.exclude('tests.test_octavemagic')
if not have['rpy2'] or not have['numpy']:
sec.exclude('rmagic')
sec.exclude('tests.test_rmagic')
# autoreload does some strange stuff, so move it to its own test section
sec.exclude('autoreload')
sec.exclude('tests.test_autoreload')
test_sections['autoreload'] = TestSection('autoreload',
['IPython.extensions.autoreload', 'IPython.extensions.tests.test_autoreload'])
test_group_names.append('autoreload')
# qt:
test_sections['qt'].requires('zmq', 'qt', 'pygments')
# html:
sec = test_sections['html']
MinRK
update test requirements for IPython.html
r13177 sec.requires('zmq', 'tornado', 'requests')
Thomas Kluyver
Start refactoring test machinery
r12608 # 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.
sec.exclude('static')
sec.exclude('fabfile')
if not have['jinja2']:
sec.exclude('notebookapp')
MinRK
exclude html nbconvert tests if nbconvert is not importable
r13948 if not have['pygments'] or not have['jinja2']:
sec.exclude('nbconvert')
Thomas Kluyver
Start refactoring test machinery
r12608
# config:
# Config files aren't really importable stand-alone
test_sections['config'].exclude('profile')
# nbconvert:
sec = test_sections['nbconvert']
MinRK
exclude html nbconvert tests if nbconvert is not importable
r13948 sec.requires('pygments', 'jinja2')
Thomas Kluyver
Start refactoring test machinery
r12608 # Exclude nbconvert directories containing config files used to test.
# Executing the config files with iptest would cause an exception.
sec.exclude('tests.files')
sec.exclude('exporters.tests.files')
Min RK
add nbconvert serve exclusions without tornado
r12625 if not have['tornado']:
sec.exclude('nbconvert.post_processors.serve')
sec.exclude('nbconvert.post_processors.tests.test_serve')
Fernando Perez
Added diagnostics printout at the end of the test suite....
r2496
Thomas Kluyver
Start refactoring test machinery
r12608 #-----------------------------------------------------------------------------
# Functions and classes
#-----------------------------------------------------------------------------
Brian Granger
Minor cleanup in iptest.py and growl.py.
r2512
Thomas Kluyver
Start refactoring test machinery
r12608 def check_exclusions_exist():
Thomas Kluyver
Better coverage reporting
r12612 from IPython.utils.path import get_ipython_package_dir
from IPython.utils.warn import warn
Thomas Kluyver
Start refactoring test machinery
r12608 parent = os.path.dirname(get_ipython_package_dir())
for sec in test_sections:
for pattern in sec.exclusions:
fullpath = pjoin(parent, pattern)
if not os.path.exists(fullpath) and not glob.glob(fullpath + '.*'):
warn("Excluding nonexistent file: %r" % pattern)
Brian Granger
Minor cleanup in iptest.py and growl.py.
r2512
Thomas Kluyver
Start refactoring test machinery
r12608
class ExclusionPlugin(Plugin):
"""A nose plugin to effect our exclusions of files and directories.
Fernando Perez
Fix test suite when Twisted not available, cleanups to iptest for clarity.
r2454 """
Thomas Kluyver
Start refactoring test machinery
r12608 name = 'exclusions'
score = 3000 # Should come before any other plugins
MinRK
move IPython.inprocess to IPython.kernel.inprocess
r9375
Thomas Kluyver
Start refactoring test machinery
r12608 def __init__(self, exclude_patterns=None):
"""
Parameters
----------
exclude_patterns : sequence of strings, optional
Thomas Kluyver
Use plain string searching for test exclusions....
r12756 Filenames containing these patterns (as raw strings, not as regular
expressions) are excluded from the tests.
Thomas Kluyver
Start refactoring test machinery
r12608 """
Thomas Kluyver
Use plain string searching for test exclusions....
r12756 self.exclude_patterns = exclude_patterns or []
Thomas Kluyver
Start refactoring test machinery
r12608 super(ExclusionPlugin, self).__init__()
def options(self, parser, env=os.environ):
Plugin.options(self, parser, env)
MinRK
warn on nonexistent exclusions
r7121
Thomas Kluyver
Start refactoring test machinery
r12608 def configure(self, options, config):
Plugin.configure(self, options, config)
# Override nose trying to disable plugin.
self.enabled = True
def wantFile(self, filename):
"""Return whether the given filename should be scanned for tests.
"""
Thomas Kluyver
Use plain string searching for test exclusions....
r12756 if any(pat in filename for pat in self.exclude_patterns):
Thomas Kluyver
Start refactoring test machinery
r12608 return False
return None
def wantDirectory(self, directory):
"""Return whether the given directory should be scanned for tests.
"""
Thomas Kluyver
Use plain string searching for test exclusions....
r12756 if any(pat in directory for pat in self.exclude_patterns):
Thomas Kluyver
Start refactoring test machinery
r12608 return False
return None
Fernando Perez
Work in multiple places to improve state of the test suite....
r2398
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 class StreamCapturer(Thread):
Thomas Kluyver
StreamCapturer should die if main process crashes.
r13517 daemon = True # Don't hang if main thread crashes
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 started = False
def __init__(self):
super(StreamCapturer, self).__init__()
self.streams = []
self.buffer = BytesIO()
Thomas Kluyver
Simplify StreamCapturer for subprocess testing...
r13405 self.readfd, self.writefd = os.pipe()
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 self.buffer_lock = Lock()
self.stop = Event()
def run(self):
self.started = True
Thomas Kluyver
Simplify StreamCapturer for subprocess testing...
r13405
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 while not self.stop.is_set():
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423 chunk = os.read(self.readfd, 1024)
Thomas Kluyver
Simplify StreamCapturer for subprocess testing...
r13405
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423 with self.buffer_lock:
self.buffer.write(chunk)
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973
Thomas Kluyver
Simplify StreamCapturer for subprocess testing...
r13405 os.close(self.readfd)
os.close(self.writefd)
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 def reset_buffer(self):
with self.buffer_lock:
self.buffer.truncate(0)
self.buffer.seek(0)
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 def get_buffer(self):
with self.buffer_lock:
return self.buffer.getvalue()
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 def ensure_started(self):
if not self.started:
self.start()
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423 def halt(self):
"""Safely stop the thread."""
if not self.started:
return
self.stop.set()
os.write(self.writefd, b'wake up') # Ensure we're not locked in a read()
self.join()
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 class SubprocessStreamCapturePlugin(Plugin):
name='subprocstreams'
def __init__(self):
Plugin.__init__(self)
self.stream_capturer = StreamCapturer()
Thomas Kluyver
Option to spew subprocess streams during tests...
r13824 self.destination = os.environ.get('IPTEST_SUBPROC_STREAMS', 'capture')
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 # This is ugly, but distant parts of the test machinery need to be able
Thomas Kluyver
Simplify StreamCapturer for subprocess testing...
r13405 # to redirect streams, so we make the object globally accessible.
Thomas Kluyver
Option to spew subprocess streams during tests...
r13824 nose.iptest_stdstreams_fileno = self.get_write_fileno
def get_write_fileno(self):
if self.destination == 'capture':
self.stream_capturer.ensure_started()
return self.stream_capturer.writefd
elif self.destination == 'discard':
return os.open(os.devnull, os.O_WRONLY)
else:
return sys.__stdout__.fileno()
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973
def configure(self, options, config):
Plugin.configure(self, options, config)
# Override nose trying to disable plugin.
Thomas Kluyver
Option to spew subprocess streams during tests...
r13824 if self.destination == 'capture':
self.enabled = True
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973
def startTest(self, test):
# Reset log capture
self.stream_capturer.reset_buffer()
def formatFailure(self, test, err):
# Show output
ec, ev, tb = err
Thomas Kluyver
Don't show subprocess output if there isn't any
r13155 captured = self.stream_capturer.get_buffer().decode('utf-8', 'replace')
if captured.strip():
ev = safe_str(ev)
out = [ev, '>> begin captured subprocess output <<',
captured,
'>> end captured subprocess output <<']
return ec, '\n'.join(out), tb
return err
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973
formatError = formatFailure
def finalize(self, result):
Thomas Kluyver
Don't use select() in StreamCapturer...
r13423 self.stream_capturer.halt()
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972 def run_iptest():
"""Run the IPython test suite using nose.
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972 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.
Fernando Perez
Add module I forgot
r1574 """
Thomas Kluyver
Make separate function to monkeypatch Xunit.
r6102 # Apply our monkeypatch to Xunit
Thomas Kluyver
Only monkeypatch xunit when the tests are run using it.
r6113 if '--with-xunit' in sys.argv and not hasattr(Xunit, 'orig_addError'):
Thomas Kluyver
Make separate function to monkeypatch Xunit.
r6102 monkeypatch_xunit()
Fernando Perez
Add module I forgot
r1574
Bernardo B. Marques
remove all trailling spaces
r4872 warnings.filterwarnings('ignore',
Fernando Perez
Add module I forgot
r1574 'This will be removed soon. Use IPython.testing.util instead')
Thomas Kluyver
Add test suite for autoreload extension...
r11073
Thomas Kluyver
Allow 'iptest IPython.lib' as well as 'iptest lib'
r12622 arg1 = sys.argv[1]
if arg1 in test_sections:
section = test_sections[arg1]
sys.argv[1:2] = section.includes
elif arg1.startswith('IPython.') and arg1[8:] in test_sections:
section = test_sections[arg1[8:]]
Thomas Kluyver
Allow drilling down to individual tests using iptest command
r12620 sys.argv[1:2] = section.includes
else:
section = TestSection(arg1, includes=[arg1])
Fernando Perez
Add module I forgot
r1574
Fernando Perez
Fix tests to return consistent results regardless of how they are called....
r2487 argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks
Bernardo B. Marques
remove all trailling spaces
r4872
Fernando Perez
Massive amount of work to improve the test suite, restores doctests....
r2414 '--with-ipdoctest',
'--ipdoctest-tests','--ipdoctest-extension=txt',
Bernardo B. Marques
remove all trailling spaces
r4872
Fernando Perez
Fixes to testing system: ipdocetst plugin wasn't being properly loaded.
r1761 # 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',
]
MinRK
skip crash tests by default
r8201 if '-a' not in argv and '-A' not in argv:
argv = argv + ['-a', '!crash']
Fernando Perez
Add module I forgot
r1574
Fernando Perez
Robustness fixes in test suite machinery....
r2494 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')
Fernando Perez
Add module I forgot
r1574
Matthew Brett
BF - allow nose with-doctest setting in environment...
r4567 # use our plugin for doctesting. It will remove the standard doctest plugin
# if it finds it enabled
Thomas Kluyver
Capture output from subprocs during test, and display on failure...
r12973 plugins = [ExclusionPlugin(section.excludes), IPythonDoctest(), KnownFailure(),
SubprocessStreamCapturePlugin() ]
Thomas Kluyver
Start refactoring test machinery
r12608
# Use working directory set by parent process (see iptestcontroller)
if 'IPTEST_WORKING_DIR' in os.environ:
os.chdir(os.environ['IPTEST_WORKING_DIR'])
Fernando Perez
Ensure that in-process test group doesn't create global IPython singleton....
r8489
# 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.
Thomas Kluyver
Allow drilling down to individual tests using iptest command
r12620 if 'kernel.inprocess' not in section.name:
Thomas Kluyver
Better coverage reporting
r12612 from IPython.testing import globalipapp
Fernando Perez
Ensure that in-process test group doesn't create global IPython singleton....
r8489 globalipapp.start_ipython()
Fernando Perez
Massive amount of work to improve the test suite, restores doctests....
r2414 # Now nose can run
Matthew Brett
BF - allow nose with-doctest setting in environment...
r4567 TestProgram(argv=argv, addplugins=plugins)
Brian Granger
Refactored iptest to include the iptestall capabilities....
r1972
if __name__ == '__main__':
Thomas Kluyver
Split out iptestcontroller to control test process.
r12607 run_iptest()
Thomas Kluyver
Better coverage reporting
r12612