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 IPython -- -vvs. In this form the script simply calls nose, but with special command line flags and plugins loaded. Options after -- are passed to nose.

4 Classes

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

Bases: object

__init__(name, includes)
class IPython.testing.iptest.ExclusionPlugin(exclude_patterns=None)

Bases: nose.plugins.base.Plugin

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


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({'RTD_PYTHON_VERSION_35': '3.5.10', 'HOSTNAME': 'build-14811803-project-201-ipython', 'RTD_PYTHON_VERSION_27': '2.7.18', 'RTD_PYTHON_VERSION_36': '3.6.12', 'RTD_PYTHON_VERSION_37': '3.7.9', 'APPDIR': '/app', 'RTD_PYTHON_VERSION_38': '3.8.6', 'HOME': '/home/docs', 'RTD_SETUPTOOLS_VERSION': '45.1.0', 'NO_COLOR': '1', 'READTHEDOCS': 'True', 'CONDA_ENVS_PATH': '/home/docs/checkouts/', 'RTD_PYPY_VERSION_35': 'pypy3.5-7.0.0', 'READTHEDOCS_PROJECT': 'ipython', 'PATH': '/home/docs/checkouts/', 'RTD_PIP_VERSION': '20.0.1', 'LANG': 'C.UTF-8', 'READTHEDOCS_LANGUAGE': 'en', 'DEBIAN_FRONTEND': 'noninteractive', 'RTD_VIRTUALENV_VERSION': '16.7.9', 'CONDA_DEFAULT_ENV': 'stable', 'RTD_CONDA_VERSION': '4.6.14', 'READTHEDOCS_VERSION': 'stable', 'PWD': '/home/docs/checkouts/', 'PYENV_ROOT': '/home/docs/.pyenv', 'DOCUTILSCONFIG': '/home/docs/checkouts/', 'PYDEVD_USE_FRAME_EVAL': 'NO'}))

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().


Return whether the given directory should be scanned for tests.


Return whether the given filename should be scanned for tests.

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

Bases: threading.Thread


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.


Safely stop the thread.


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

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.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

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.