Warning

This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.

Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: testing.iptest

IPython Test Suite Runner.

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 calling this script (with different arguments) recursively. This 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.

4 Classes

class IPython.testing.iptest.TestSection(name, includes)

Bases: object

__init__(name, includes)

Initialize self. See help(type(self)) for accurate signature.

class IPython.testing.iptest.ExclusionPlugin(exclude_patterns=None)

Bases: nose.plugins.base.Plugin

A nose plugin to effect our exclusions of files and directories.

__init__(exclude_patterns=None)
Parameters:exclude_patterns (sequence of strings, optional) – Filenames containing these patterns (as raw strings, not as regular expressions) are excluded from the tests.
configure(options, config)

Configure the plugin and system, based on selected options.

The base plugin class sets the plugin to enabled if the enable option for the plugin (self.enableOpt) is true.

options(parser, env=environ({'HOSTNAME': 'build-8253301-project-201-ipython', 'APPDIR': '/app', 'HOME': '/home/docs', 'OLDPWD': '/home/docs', 'READTHEDOCS': 'True', 'CONDA_ENVS_PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ipython/conda', 'READTHEDOCS_PROJECT': 'ipython', 'PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ipython/conda/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/docs/.conda/bin', 'LANG': 'C.UTF-8', 'DEBIAN_FRONTEND': 'noninteractive', 'CONDA_DEFAULT_ENV': 'latest', 'BIN_PATH': '/home/docs/checkouts/readthedocs.org/user_builds/ipython/conda/latest/bin', 'READTHEDOCS_VERSION': 'latest', 'PWD': '/home/docs/checkouts/readthedocs.org/user_builds/ipython/checkouts/latest/docs/source', 'DOCUTILSCONFIG': '/home/docs/checkouts/readthedocs.org/user_builds/ipython/checkouts/latest/docs/source/docutils.conf'}))

Register commandline options.

Implement this method for normal options behavior with protection from OptionConflictErrors. If you override this method and want the default –with-$name option to be registered, be sure to call super().

wantDirectory(directory)

Return whether the given directory should be scanned for tests.

wantFile(filename)

Return whether the given filename should be scanned for tests.

class IPython.testing.iptest.StreamCapturer(echo=False)

Bases: threading.Thread

__init__(echo=False)

This constructor should always be called with keyword arguments. Arguments are:

group should be None; reserved for future extension when a ThreadGroup class is implemented.

target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.

name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.

args is the argument tuple for the target invocation. Defaults to ().

kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.

If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.

halt()

Safely stop the thread.

run()

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

class IPython.testing.iptest.SubprocessStreamCapturePlugin

Bases: nose.plugins.base.Plugin

__init__()

Initialize self. See help(type(self)) for accurate signature.

configure(options, config)

Configure the plugin and system, based on selected options.

The base plugin class sets the plugin to enabled if the enable option for the plugin (self.enableOpt) is true.

5 Functions

IPython.testing.iptest.monkeypatch_xunit()
IPython.testing.iptest.extract_version(mod)
IPython.testing.iptest.test_for(item, min_version=None, callback=<function extract_version>)

Test to see if item is importable, and optionally check against a minimum version.

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:

In [1]: import sys

In [2]: from IPython.testing.iptest import test_for

In [3]: test_for('sys', (2,6), callback=lambda sys: sys.version_info)
Out[3]: True
IPython.testing.iptest.check_exclusions_exist()
IPython.testing.iptest.run_iptest()

Run the IPython test suite using nose.

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.