iptest.py
100 lines
| 3.9 KiB
| text/x-python
|
PythonLexer
Fernando Perez
|
r1574 | # -*- coding: utf-8 -*- | ||
"""IPython Test Suite Runner. | ||||
Fernando Perez
|
r1851 | |||
This module provides a main entry point to a user script to test IPython itself | ||||
from the command line. The main() routine can be used in a similar manner to | ||||
the ``nosetests`` script, and it takes similar arguments, but if no arguments | ||||
are given it defaults to testing all of IPython. This should be preferred to | ||||
using plain ``nosetests`` because a number of nose plugins necessary to test | ||||
IPython correctly are automatically configured by this code. | ||||
Fernando Perez
|
r1574 | """ | ||
Fernando Perez
|
r1851 | #----------------------------------------------------------------------------- | ||
# Module imports | ||||
#----------------------------------------------------------------------------- | ||||
# stdlib | ||||
Fernando Perez
|
r1574 | import sys | ||
import warnings | ||||
Fernando Perez
|
r1851 | # third-party | ||
Fernando Perez
|
r1574 | import nose.plugins.builtin | ||
Fernando Perez
|
r1851 | from nose.core import TestProgram | ||
Fernando Perez
|
r1574 | |||
Fernando Perez
|
r1851 | # Our own imports | ||
Fernando Perez
|
r1574 | from IPython.testing.plugin.ipdoctest import IPythonDoctest | ||
Fernando Perez
|
r1851 | #----------------------------------------------------------------------------- | ||
# Constants and globals | ||||
#----------------------------------------------------------------------------- | ||||
# For the IPythonDoctest plugin, we need to exclude certain patterns that cause | ||||
# testing problems. We should strive to minimize the number of skipped | ||||
# modules, since this means untested code. As the testing machinery | ||||
# solidifies, this list should eventually become empty. | ||||
EXCLUDE = ['IPython/external/', | ||||
'IPython/platutils_win32', | ||||
'IPython/frontend/cocoa', | ||||
'IPython_doctest_plugin', | ||||
'IPython/Gnuplot', | ||||
'IPython/Extensions/ipy_', | ||||
'IPython/Extensions/clearcmd', | ||||
'IPython/Extensions/PhysicalQIn', | ||||
'IPython/Extensions/scitedirector', | ||||
] | ||||
#----------------------------------------------------------------------------- | ||||
# Functions and classes | ||||
#----------------------------------------------------------------------------- | ||||
Fernando Perez
|
r1574 | def main(): | ||
"""Run the IPython test suite. | ||||
""" | ||||
warnings.filterwarnings('ignore', | ||||
'This will be removed soon. Use IPython.testing.util instead') | ||||
Brian Granger
|
r1888 | argv = sys.argv + [ | ||
# Loading ipdoctest causes problems with Twisted. | ||||
# I am removing this as a temporary fix to get the | ||||
# test suite back into working shape. Our nose | ||||
# plugin needs to be gone through with a fine | ||||
# toothed comb to find what is causing the problem. | ||||
# '--with-ipdoctest', | ||||
Fernando Perez
|
r1910 | '--ipdoctest-tests','--ipdoctest-extension=txt', | ||
Fernando Perez
|
r1761 | '--detailed-errors', | ||
Fernando Perez
|
r1574 | |||
Fernando Perez
|
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', | ||||
] | ||||
Fernando Perez
|
r1574 | |||
Fernando Perez
|
r1848 | # Detect if any tests were required by explicitly calling an IPython | ||
# submodule or giving a specific path | ||||
has_tests = False | ||||
Fernando Perez
|
r1574 | for arg in sys.argv: | ||
Fernando Perez
|
r1848 | if 'IPython' in arg or arg.endswith('.py') or \ | ||
(':' in arg and '.py' in arg): | ||||
has_tests = True | ||||
Fernando Perez
|
r1574 | break | ||
Fernando Perez
|
r1910 | |||
Fernando Perez
|
r1848 | # If nothing was specifically requested, test full IPython | ||
if not has_tests: | ||||
Fernando Perez
|
r1574 | argv.append('IPython') | ||
Fernando Perez
|
r1910 | # Construct list of plugins, omitting the existing doctest plugin, which | ||
# ours replaces (and extends). | ||||
Fernando Perez
|
r1851 | plugins = [IPythonDoctest(EXCLUDE)] | ||
Fernando Perez
|
r1761 | for p in nose.plugins.builtin.plugins: | ||
plug = p() | ||||
if plug.name == 'doctest': | ||||
continue | ||||
#print '*** adding plugin:',plug.name # dbg | ||||
plugins.append(plug) | ||||
Fernando Perez
|
r1574 | TestProgram(argv=argv,plugins=plugins) | ||