diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 0a99b99..9e4f74b 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -1,15 +1,53 @@ # -*- coding: utf-8 -*- """IPython Test Suite Runner. + +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. """ +#----------------------------------------------------------------------------- +# Module imports +#----------------------------------------------------------------------------- + +# stdlib import sys import warnings -from nose.core import TestProgram +# third-party import nose.plugins.builtin +from nose.core import TestProgram +# Our own imports from IPython.testing.plugin.ipdoctest import IPythonDoctest +#----------------------------------------------------------------------------- +# 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', + 'IPython/testing/plugin', + ] + +#----------------------------------------------------------------------------- +# Functions and classes +#----------------------------------------------------------------------------- + def main(): """Run the IPython test suite. """ @@ -42,8 +80,8 @@ def main(): if not has_tests: argv.append('IPython') - # construct list of plugins, omitting the existing doctest plugin - plugins = [IPythonDoctest()] + # Construct list of plugins, omitting the existing doctest plugin. + plugins = [IPythonDoctest(EXCLUDE)] for p in nose.plugins.builtin.plugins: plug = p() if plug.name == 'doctest': diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index 59cb945..577386c 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -677,6 +677,22 @@ class ExtensionDoctest(doctests.Doctest): name = 'extdoctest' # call nosetests with --with-extdoctest enabled = True + def __init__(self,exclude_patterns=None): + """Create a new ExtensionDoctest plugin. + + Parameters + ---------- + + exclude_patterns : sequence of strings, optional + These patterns are compiled as regular expressions, subsequently used + to exclude any filename which matches them from inclusion in the test + suite (using pattern.search(), NOT pattern.match() ). + """ + if exclude_patterns is None: + exclude_patterns = [] + self.exclude_patterns = map(re.compile,exclude_patterns) + doctests.Doctest.__init__(self) + def options(self, parser, env=os.environ): Plugin.options(self, parser, env) parser.add_option('--doctest-tests', action='store_true', @@ -783,20 +799,8 @@ class ExtensionDoctest(doctests.Doctest): """ #print '*** ipdoctest- wantFile:',filename # dbg - # XXX - temporarily hardcoded list, will move to driver later - exclude = ['IPython/external/', - 'IPython/platutils_win32', - 'IPython/frontend/cocoa', - 'IPython_doctest_plugin', - 'IPython/Gnuplot', - 'IPython/Extensions/ipy_', - 'IPython/Extensions/PhysicalQIn', - 'IPython/Extensions/scitedirector', - 'IPython/testing/plugin', - ] - - for fex in exclude: - if fex in filename: # substring + for pat in self.exclude_patterns: + if pat.search(filename): #print '###>>> SKIP:',filename # dbg return False diff --git a/IPython/tests/tclass.py b/IPython/tests/tclass.py new file mode 100644 index 0000000..9b62fde --- /dev/null +++ b/IPython/tests/tclass.py @@ -0,0 +1,6 @@ +"""Simple script to instantiate a class for testing %run""" + +class foo: pass + +def f(): + foo()