Show More
@@ -0,0 +1,6 b'' | |||||
|
1 | """Simple script to instantiate a class for testing %run""" | |||
|
2 | ||||
|
3 | class foo: pass | |||
|
4 | ||||
|
5 | def f(): | |||
|
6 | foo() |
@@ -1,15 +1,53 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """IPython Test Suite Runner. |
|
2 | """IPython Test Suite Runner. | |
|
3 | ||||
|
4 | This module provides a main entry point to a user script to test IPython itself | |||
|
5 | from the command line. The main() routine can be used in a similar manner to | |||
|
6 | the ``nosetests`` script, and it takes similar arguments, but if no arguments | |||
|
7 | are given it defaults to testing all of IPython. This should be preferred to | |||
|
8 | using plain ``nosetests`` because a number of nose plugins necessary to test | |||
|
9 | IPython correctly are automatically configured by this code. | |||
3 | """ |
|
10 | """ | |
4 |
|
11 | |||
|
12 | #----------------------------------------------------------------------------- | |||
|
13 | # Module imports | |||
|
14 | #----------------------------------------------------------------------------- | |||
|
15 | ||||
|
16 | # stdlib | |||
5 | import sys |
|
17 | import sys | |
6 | import warnings |
|
18 | import warnings | |
7 |
|
19 | |||
8 | from nose.core import TestProgram |
|
20 | # third-party | |
9 | import nose.plugins.builtin |
|
21 | import nose.plugins.builtin | |
|
22 | from nose.core import TestProgram | |||
10 |
|
23 | |||
|
24 | # Our own imports | |||
11 | from IPython.testing.plugin.ipdoctest import IPythonDoctest |
|
25 | from IPython.testing.plugin.ipdoctest import IPythonDoctest | |
12 |
|
26 | |||
|
27 | #----------------------------------------------------------------------------- | |||
|
28 | # Constants and globals | |||
|
29 | #----------------------------------------------------------------------------- | |||
|
30 | ||||
|
31 | # For the IPythonDoctest plugin, we need to exclude certain patterns that cause | |||
|
32 | # testing problems. We should strive to minimize the number of skipped | |||
|
33 | # modules, since this means untested code. As the testing machinery | |||
|
34 | # solidifies, this list should eventually become empty. | |||
|
35 | EXCLUDE = ['IPython/external/', | |||
|
36 | 'IPython/platutils_win32', | |||
|
37 | 'IPython/frontend/cocoa', | |||
|
38 | 'IPython_doctest_plugin', | |||
|
39 | 'IPython/Gnuplot', | |||
|
40 | 'IPython/Extensions/ipy_', | |||
|
41 | 'IPython/Extensions/clearcmd', | |||
|
42 | 'IPython/Extensions/PhysicalQIn', | |||
|
43 | 'IPython/Extensions/scitedirector', | |||
|
44 | 'IPython/testing/plugin', | |||
|
45 | ] | |||
|
46 | ||||
|
47 | #----------------------------------------------------------------------------- | |||
|
48 | # Functions and classes | |||
|
49 | #----------------------------------------------------------------------------- | |||
|
50 | ||||
13 | def main(): |
|
51 | def main(): | |
14 | """Run the IPython test suite. |
|
52 | """Run the IPython test suite. | |
15 | """ |
|
53 | """ | |
@@ -42,8 +80,8 b' def main():' | |||||
42 | if not has_tests: |
|
80 | if not has_tests: | |
43 | argv.append('IPython') |
|
81 | argv.append('IPython') | |
44 |
|
82 | |||
45 |
# |
|
83 | # Construct list of plugins, omitting the existing doctest plugin. | |
46 | plugins = [IPythonDoctest()] |
|
84 | plugins = [IPythonDoctest(EXCLUDE)] | |
47 | for p in nose.plugins.builtin.plugins: |
|
85 | for p in nose.plugins.builtin.plugins: | |
48 | plug = p() |
|
86 | plug = p() | |
49 | if plug.name == 'doctest': |
|
87 | if plug.name == 'doctest': |
@@ -677,6 +677,22 b' class ExtensionDoctest(doctests.Doctest):' | |||||
677 | name = 'extdoctest' # call nosetests with --with-extdoctest |
|
677 | name = 'extdoctest' # call nosetests with --with-extdoctest | |
678 | enabled = True |
|
678 | enabled = True | |
679 |
|
679 | |||
|
680 | def __init__(self,exclude_patterns=None): | |||
|
681 | """Create a new ExtensionDoctest plugin. | |||
|
682 | ||||
|
683 | Parameters | |||
|
684 | ---------- | |||
|
685 | ||||
|
686 | exclude_patterns : sequence of strings, optional | |||
|
687 | These patterns are compiled as regular expressions, subsequently used | |||
|
688 | to exclude any filename which matches them from inclusion in the test | |||
|
689 | suite (using pattern.search(), NOT pattern.match() ). | |||
|
690 | """ | |||
|
691 | if exclude_patterns is None: | |||
|
692 | exclude_patterns = [] | |||
|
693 | self.exclude_patterns = map(re.compile,exclude_patterns) | |||
|
694 | doctests.Doctest.__init__(self) | |||
|
695 | ||||
680 | def options(self, parser, env=os.environ): |
|
696 | def options(self, parser, env=os.environ): | |
681 | Plugin.options(self, parser, env) |
|
697 | Plugin.options(self, parser, env) | |
682 | parser.add_option('--doctest-tests', action='store_true', |
|
698 | parser.add_option('--doctest-tests', action='store_true', | |
@@ -783,20 +799,8 b' class ExtensionDoctest(doctests.Doctest):' | |||||
783 | """ |
|
799 | """ | |
784 | #print '*** ipdoctest- wantFile:',filename # dbg |
|
800 | #print '*** ipdoctest- wantFile:',filename # dbg | |
785 |
|
801 | |||
786 | # XXX - temporarily hardcoded list, will move to driver later |
|
802 | for pat in self.exclude_patterns: | |
787 | exclude = ['IPython/external/', |
|
803 | if pat.search(filename): | |
788 | 'IPython/platutils_win32', |
|
|||
789 | 'IPython/frontend/cocoa', |
|
|||
790 | 'IPython_doctest_plugin', |
|
|||
791 | 'IPython/Gnuplot', |
|
|||
792 | 'IPython/Extensions/ipy_', |
|
|||
793 | 'IPython/Extensions/PhysicalQIn', |
|
|||
794 | 'IPython/Extensions/scitedirector', |
|
|||
795 | 'IPython/testing/plugin', |
|
|||
796 | ] |
|
|||
797 |
|
||||
798 | for fex in exclude: |
|
|||
799 | if fex in filename: # substring |
|
|||
800 | #print '###>>> SKIP:',filename # dbg |
|
804 | #print '###>>> SKIP:',filename # dbg | |
801 | return False |
|
805 | return False | |
802 |
|
806 |
General Comments 0
You need to be logged in to leave comments.
Login now