##// END OF EJS Templates
First failed attempt to get the test suite to run.
Brian Granger -
Show More
@@ -1,7 +1,5 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3
4 def test_import_userconfig():
5 from IPython.config import userconfig
6 4
7 5
@@ -1,65 +1,62 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3
4 4 def test_import_completer():
5 5 from IPython.core import completer
6 6
7 7 def test_import_crashhandler():
8 8 from IPython.core import crashhandler
9 9
10 10 def test_import_debugger():
11 11 from IPython.core import debugger
12 12
13 13 def test_import_fakemodule():
14 14 from IPython.core import fakemodule
15 15
16 16 def test_import_excolors():
17 17 from IPython.core import excolors
18 18
19 19 def test_import_history():
20 20 from IPython.core import history
21 21
22 22 def test_import_hooks():
23 23 from IPython.core import hooks
24 24
25 25 def test_import_ipapi():
26 26 from IPython.core import ipapi
27 27
28 28 def test_import_iplib():
29 29 from IPython.core import iplib
30 30
31 31 def test_import_logger():
32 32 from IPython.core import logger
33 33
34 34 def test_import_macro():
35 35 from IPython.core import macro
36 36
37 37 def test_import_magic():
38 38 from IPython.core import magic
39 39
40 40 def test_import_oinspect():
41 41 from IPython.core import oinspect
42 42
43 43 def test_import_outputtrap():
44 44 from IPython.core import outputtrap
45 45
46 46 def test_import_prefilter():
47 47 from IPython.core import prefilter
48 48
49 49 def test_import_prompts():
50 50 from IPython.core import prompts
51 51
52 52 def test_import_release():
53 53 from IPython.core import release
54 54
55 55 def test_import_shadowns():
56 56 from IPython.core import shadowns
57 57
58 def test_import_shell():
59 from IPython.core import shell
60
61 58 def test_import_ultratb():
62 59 from IPython.core import ultratb
63 60
64 61 def test_import_usage():
65 62 from IPython.core import usage
1 NO CONTENT: modified file
@@ -1,334 +1,324 b''
1 1 # -*- coding: utf-8 -*-
2 2 """IPython Test Suite Runner.
3 3
4 4 This module provides a main entry point to a user script to test IPython
5 5 itself from the command line. There are two ways of running this script:
6 6
7 7 1. With the syntax `iptest all`. This runs our entire test suite by
8 8 calling this script (with different arguments) or trial recursively. This
9 9 causes modules and package to be tested in different processes, using nose
10 10 or trial where appropriate.
11 11 2. With the regular nose syntax, like `iptest -vvs IPython`. In this form
12 12 the script simply calls nose, but with special command line flags and
13 13 plugins loaded.
14 14
15 15 For now, this script requires that both nose and twisted are installed. This
16 16 will change in the future.
17 17 """
18 18
19 19 #-----------------------------------------------------------------------------
20 20 # Module imports
21 21 #-----------------------------------------------------------------------------
22 22
23 23 import os
24 24 import os.path as path
25 25 import sys
26 26 import subprocess
27 27 import tempfile
28 28 import time
29 29 import warnings
30 30
31 31 import nose.plugins.builtin
32 32 from nose.core import TestProgram
33 33
34 34 from IPython.utils.platutils import find_cmd
35 from IPython.testing.plugin.ipdoctest import IPythonDoctest
35 # from IPython.testing.plugin.ipdoctest import IPythonDoctest
36 36
37 37 pjoin = path.join
38 38
39 39 #-----------------------------------------------------------------------------
40 40 # Logic for skipping doctests
41 41 #-----------------------------------------------------------------------------
42 42
43 43 def test_for(mod):
44 44 """Test to see if mod is importable."""
45 45 try:
46 46 __import__(mod)
47 47 except ImportError:
48 48 return False
49 49 else:
50 50 return True
51 51
52 52 have_curses = test_for('_curses')
53 53 have_wx = test_for('wx')
54 54 have_wx_aui = test_for('wx.aui')
55 55 have_zi = test_for('zope.interface')
56 56 have_twisted = test_for('twisted')
57 57 have_foolscap = test_for('foolscap')
58 58 have_objc = test_for('objc')
59 59 have_pexpect = test_for('pexpect')
60 60 have_gtk = test_for('gtk')
61 61 have_gobject = test_for('gobject')
62 62
63 63
64 64 def make_exclude():
65 65
66 66 # For the IPythonDoctest plugin, we need to exclude certain patterns that cause
67 67 # testing problems. We should strive to minimize the number of skipped
68 68 # modules, since this means untested code. As the testing machinery
69 69 # solidifies, this list should eventually become empty.
70 70 EXCLUDE = [pjoin('IPython', 'external'),
71 71 pjoin('IPython', 'frontend', 'process', 'winprocess.py'),
72 72 pjoin('IPython_doctest_plugin'),
73 pjoin('IPython', 'extensions', 'ipy_'),
74 pjoin('IPython', 'extensions', 'PhysicalQInput'),
75 pjoin('IPython', 'extensions', 'PhysicalQInteractive'),
76 pjoin('IPython', 'extensions', 'InterpreterPasteInput'),
77 pjoin('IPython', 'extensions', 'scitedirector'),
78 pjoin('IPython', 'extensions', 'numeric_formats'),
73 pjoin('IPython', 'quarantine'),
74 pjoin('IPython', 'deathrow'),
79 75 pjoin('IPython', 'testing', 'attic'),
80 76 pjoin('IPython', 'testing', 'tools'),
81 77 pjoin('IPython', 'testing', 'mkdoctests'),
82 78 pjoin('IPython', 'lib', 'inputhook')
83 79 ]
84 80
85 81 if not have_wx:
86 EXCLUDE.append(pjoin('IPython', 'extensions', 'igrid'))
87 82 EXCLUDE.append(pjoin('IPython', 'gui'))
88 83 EXCLUDE.append(pjoin('IPython', 'frontend', 'wx'))
89 84 EXCLUDE.append(pjoin('IPython', 'lib', 'inputhookwx'))
90 85
91 86 if not have_gtk or not have_gobject:
92 87 EXCLUDE.append(pjoin('IPython', 'lib', 'inputhookgtk'))
93 88
94 89 if not have_wx_aui:
95 90 EXCLUDE.append(pjoin('IPython', 'gui', 'wx', 'wxIPython'))
96 91
97 92 if not have_objc:
98 93 EXCLUDE.append(pjoin('IPython', 'frontend', 'cocoa'))
99 94
100 if not have_curses:
101 EXCLUDE.append(pjoin('IPython', 'extensions', 'ibrowse'))
102
103 95 if not sys.platform == 'win32':
104 96 EXCLUDE.append(pjoin('IPython', 'utils', 'platutils_win32'))
105 97
106 98 # These have to be skipped on win32 because the use echo, rm, cd, etc.
107 99 # See ticket https://bugs.launchpad.net/bugs/366982
108 100 if sys.platform == 'win32':
109 101 EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'test_exampleip'))
110 102 EXCLUDE.append(pjoin('IPython', 'testing', 'plugin', 'dtexample'))
111 103
112 104 if not os.name == 'posix':
113 105 EXCLUDE.append(pjoin('IPython', 'utils', 'platutils_posix'))
114 106
115 107 if not have_pexpect:
116 108 EXCLUDE.append(pjoin('IPython', 'scripts', 'irunner'))
117 109
118 110 # This is scary. We still have things in frontend and testing that
119 111 # are being tested by nose that use twisted. We need to rethink
120 112 # how we are isolating dependencies in testing.
121 113 if not (have_twisted and have_zi and have_foolscap):
122 114 EXCLUDE.append(pjoin('IPython', 'frontend', 'asyncfrontendbase'))
123 115 EXCLUDE.append(pjoin('IPython', 'frontend', 'prefilterfrontend'))
124 116 EXCLUDE.append(pjoin('IPython', 'frontend', 'frontendbase'))
125 117 EXCLUDE.append(pjoin('IPython', 'frontend', 'linefrontendbase'))
126 118 EXCLUDE.append(pjoin('IPython', 'frontend', 'tests',
127 119 'test_linefrontend'))
128 120 EXCLUDE.append(pjoin('IPython', 'frontend', 'tests',
129 121 'test_frontendbase'))
130 122 EXCLUDE.append(pjoin('IPython', 'frontend', 'tests',
131 123 'test_prefilterfrontend'))
132 124 EXCLUDE.append(pjoin('IPython', 'frontend', 'tests',
133 125 'test_asyncfrontendbase')),
134 126 EXCLUDE.append(pjoin('IPython', 'testing', 'parametric'))
135 127 EXCLUDE.append(pjoin('IPython', 'testing', 'util'))
136 128 EXCLUDE.append(pjoin('IPython', 'testing', 'tests',
137 129 'test_decorators_trial'))
138 130
139 # Skip shell always because of a bug in FakeModule.
140 EXCLUDE.append(pjoin('IPython', 'core', 'shell'))
141
142 131 # This is needed for the reg-exp to match on win32 in the ipdoctest plugin.
143 132 if sys.platform == 'win32':
144 133 EXCLUDE = [s.replace('\\','\\\\') for s in EXCLUDE]
145 134
146 135 return EXCLUDE
147 136
148 137
149 138 #-----------------------------------------------------------------------------
150 139 # Functions and classes
151 140 #-----------------------------------------------------------------------------
152 141
153 142 def run_iptest():
154 143 """Run the IPython test suite using nose.
155 144
156 145 This function is called when this script is **not** called with the form
157 146 `iptest all`. It simply calls nose with appropriate command line flags
158 147 and accepts all of the standard nose arguments.
159 148 """
160 149
161 150 warnings.filterwarnings('ignore',
162 151 'This will be removed soon. Use IPython.testing.util instead')
163 152
164 153 argv = sys.argv + [
165 154 # Loading ipdoctest causes problems with Twisted.
166 155 # I am removing this as a temporary fix to get the
167 156 # test suite back into working shape. Our nose
168 157 # plugin needs to be gone through with a fine
169 158 # toothed comb to find what is causing the problem.
170 '--with-ipdoctest',
171 '--ipdoctest-tests','--ipdoctest-extension=txt',
172 '--detailed-errors',
159 # '--with-ipdoctest',
160 # '--ipdoctest-tests','--ipdoctest-extension=txt',
161 # '--detailed-errors',
173 162
174 163 # We add --exe because of setuptools' imbecility (it
175 164 # blindly does chmod +x on ALL files). Nose does the
176 165 # right thing and it tries to avoid executables,
177 166 # setuptools unfortunately forces our hand here. This
178 167 # has been discussed on the distutils list and the
179 168 # setuptools devs refuse to fix this problem!
180 169 '--exe',
181 170 ]
182 171
183 172 # Detect if any tests were required by explicitly calling an IPython
184 173 # submodule or giving a specific path
185 174 has_tests = False
186 175 for arg in sys.argv:
187 176 if 'IPython' in arg or arg.endswith('.py') or \
188 177 (':' in arg and '.py' in arg):
189 178 has_tests = True
190 179 break
191 180
192 181 # If nothing was specifically requested, test full IPython
193 182 if not has_tests:
194 183 argv.append('IPython')
195 184
196 185 # Construct list of plugins, omitting the existing doctest plugin, which
197 186 # ours replaces (and extends).
198 187 EXCLUDE = make_exclude()
199 plugins = [IPythonDoctest(EXCLUDE)]
188 plugins = []
189 # plugins = [IPythonDoctest(EXCLUDE)]
200 190 for p in nose.plugins.builtin.plugins:
201 191 plug = p()
202 192 if plug.name == 'doctest':
203 193 continue
204 194 plugins.append(plug)
205 195
206 196 TestProgram(argv=argv,plugins=plugins)
207 197
208 198
209 199 class IPTester(object):
210 200 """Call that calls iptest or trial in a subprocess.
211 201 """
212 202 def __init__(self,runner='iptest',params=None):
213 203 """ """
214 204 if runner == 'iptest':
215 205 self.runner = ['iptest','-v']
216 206 else:
217 207 self.runner = [find_cmd('trial')]
218 208 if params is None:
219 209 params = []
220 210 if isinstance(params,str):
221 211 params = [params]
222 212 self.params = params
223 213
224 214 # Assemble call
225 215 self.call_args = self.runner+self.params
226 216
227 217 if sys.platform == 'win32':
228 218 def run(self):
229 219 """Run the stored commands"""
230 220 # On Windows, cd to temporary directory to run tests. Otherwise,
231 221 # Twisted's trial may not be able to execute 'trial IPython', since
232 222 # it will confuse the IPython module name with the ipython
233 223 # execution scripts, because the windows file system isn't case
234 224 # sensitive.
235 225 # We also use os.system instead of subprocess.call, because I was
236 226 # having problems with subprocess and I just don't know enough
237 227 # about win32 to debug this reliably. Os.system may be the 'old
238 228 # fashioned' way to do it, but it works just fine. If someone
239 229 # later can clean this up that's fine, as long as the tests run
240 230 # reliably in win32.
241 231 curdir = os.getcwd()
242 232 os.chdir(tempfile.gettempdir())
243 233 stat = os.system(' '.join(self.call_args))
244 234 os.chdir(curdir)
245 235 return stat
246 236 else:
247 237 def run(self):
248 238 """Run the stored commands"""
249 239 return subprocess.call(self.call_args)
250 240
251 241
252 242 def make_runners():
253 243 """Define the top-level packages that need to be tested.
254 244 """
255 245
256 246 nose_packages = ['config', 'core', 'extensions',
257 'frontend', 'lib', 'quarantine',
247 'frontend', 'lib',
258 248 'scripts', 'testing', 'utils']
259 249 trial_packages = ['kernel']
260 250
261 251 if have_wx:
262 252 nose_packages.append('gui')
263 253
264 254 nose_packages = ['IPython.%s' % m for m in nose_packages ]
265 255 trial_packages = ['IPython.%s' % m for m in trial_packages ]
266 256
267 257 # Make runners
268 258 runners = dict()
269 259
270 260 nose_runners = dict(zip(nose_packages, [IPTester(params=v) for v in nose_packages]))
271 261 if have_zi and have_twisted and have_foolscap:
272 262 trial_runners = dict(zip(trial_packages, [IPTester('trial',params=v) for v in trial_packages]))
273 263 runners.update(nose_runners)
274 264 runners.update(trial_runners)
275 265
276 266 return runners
277 267
278 268
279 269 def run_iptestall():
280 270 """Run the entire IPython test suite by calling nose and trial.
281 271
282 272 This function constructs :class:`IPTester` instances for all IPython
283 273 modules and package and then runs each of them. This causes the modules
284 274 and packages of IPython to be tested each in their own subprocess using
285 275 nose or twisted.trial appropriately.
286 276 """
287 277
288 278 runners = make_runners()
289 279
290 280 # Run all test runners, tracking execution time
291 281 failed = {}
292 282 t_start = time.time()
293 283 for name,runner in runners.iteritems():
294 284 print '*'*77
295 285 print 'IPython test group:',name
296 286 res = runner.run()
297 287 if res:
298 288 failed[name] = res
299 289 t_end = time.time()
300 290 t_tests = t_end - t_start
301 291 nrunners = len(runners)
302 292 nfail = len(failed)
303 293 # summarize results
304 294 print
305 295 print '*'*77
306 296 print 'Ran %s test groups in %.3fs' % (nrunners, t_tests)
307 297 print
308 298 if not failed:
309 299 print 'OK'
310 300 else:
311 301 # If anything went wrong, point out what command to rerun manually to
312 302 # see the actual errors and individual summary
313 303 print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners)
314 304 for name in failed:
315 305 failed_runner = runners[name]
316 306 print '-'*40
317 307 print 'Runner failed:',name
318 308 print 'You may wish to rerun this one individually, with:'
319 309 print ' '.join(failed_runner.call_args)
320 310 print
321 311
322 312
323 313 def main():
324 314 if len(sys.argv) == 1:
325 315 run_iptestall()
326 316 else:
327 317 if sys.argv[1] == 'all':
328 318 run_iptestall()
329 319 else:
330 320 run_iptest()
331 321
332 322
333 323 if __name__ == '__main__':
334 324 main()
General Comments 0
You need to be logged in to leave comments. Login now