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 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: 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({'SSH_TTY': '/dev/pts/0', 'VIRTUAL_ENV': '/home/user/documentation/docs/ipython/venv', 'PYENV_SHELL': 'bash', 'PWD': '/home/user/documentation/docs/ipython/repository/docs', 'PS1': '(venv) ', 'MAIL': '/var/mail/user', 'OLDPWD': '/home/user/documentation/docs/ipython/repository', 'LANG': 'en_US.UTF-8', 'VIRTUAL_ENV_PROMPT': '(venv) ', 'MAKEFLAGS': 'w', 'MFLAGS': '-w', 'SHELL': '/bin/bash', 'SHLVL': '2', 'PATH': '/home/user/documentation/docs/ipython/venv/bin:~/.cargo/bin:/home/user/.pyenv/shims:/home/user/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games', 'SSH_CLIENT': '192.168.1.52 57734 22', 'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.swp=00;90:*.tmp=00;90:*.dpkg-dist=00;90:*.dpkg-old=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:', 'PYENV_ROOT': '/home/user/.pyenv', 'LOGNAME': 'user', 'USER': 'user', '_': '/usr/bin/make', 'MAKE_TERMOUT': '/dev/pts/0', 'OUTPUT_PATH': '/home/user/output/ipython', 'MAKE_TERMERR': '/dev/pts/0', 'HOME': '/home/user', 'TERM': 'rxvt-unicode-256color', 'SSH_CONNECTION': '192.168.1.52 57734 192.168.1.65 22', 'MAKELEVEL': '2', 'DOCUTILSCONFIG': '/home/user/documentation/docs/ipython/repository/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: 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 a list or tuple of arguments 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: Plugin

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