##// END OF EJS Templates
Fixes to make test suite more robust on Fedora....
Fernando Perez -
Show More
@@ -0,0 +1,51 b''
1 """Base utilities support for IPython.
2
3 Warning: this is a module that other utilities modules will import from, so it
4 can ONLY depend on the standard library, and NOTHING ELSE. In particular, this
5 module can NOT import anything from IPython, or circular dependencies will arise.
6 """
7
8 #-----------------------------------------------------------------------------
9 # Imports
10 #-----------------------------------------------------------------------------
11
12 import subprocess
13
14 #-----------------------------------------------------------------------------
15 # Functions
16 #-----------------------------------------------------------------------------
17
18 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
19 """Return (standard output,standard error) of executing cmd in a shell.
20
21 Accepts the same arguments as system(), plus:
22
23 - split(0): if true, each of stdout/err is returned as a list split on
24 newlines.
25
26 Note: a stateful version of this function is available through the
27 SystemExec class."""
28
29 if verbose or debug: print header+cmd
30 if not cmd:
31 if split:
32 return [],[]
33 else:
34 return '',''
35 if not debug:
36 p = subprocess.Popen(cmd, shell=True,
37 stdin=subprocess.PIPE,
38 stdout=subprocess.PIPE,
39 stderr=subprocess.PIPE,
40 close_fds=True)
41 pin, pout, perr = (p.stdin, p.stdout, p.stderr)
42
43 tout = pout.read().rstrip()
44 terr = perr.read().rstrip()
45 pin.close()
46 pout.close()
47 perr.close()
48 if split:
49 return tout.split('\n'),terr.split('\n')
50 else:
51 return tout,terr
@@ -71,6 +71,10 b" warnings.filterwarnings('ignore', 'the sets module is deprecated',"
71 71 warnings.filterwarnings('ignore', 'the sha module is deprecated',
72 72 DeprecationWarning)
73 73
74 # Wx on Fedora11 spits these out
75 warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch',
76 UserWarning)
77
74 78 #-----------------------------------------------------------------------------
75 79 # Logic for skipping doctests
76 80 #-----------------------------------------------------------------------------
@@ -274,33 +278,34 b' def make_runners():'
274 278 """Define the top-level packages that need to be tested.
275 279 """
276 280
277 nose_packages = ['config', 'core', 'extensions', 'frontend', 'lib',
278 'scripts', 'testing', 'utils',
279 # Note that we list the kernel here, though the bulk of it
280 # is twisted-based, because nose picks up doctests that
281 # twisted doesn't.
282 'kernel']
281 # Packages to be tested via nose, that only depend on the stdlib
282 nose_pkg_names = ['config', 'core', 'extensions', 'frontend', 'lib',
283 'scripts', 'testing', 'utils' ]
283 284 # The machinery in kernel needs twisted for real testing
284 trial_packages = ['kernel']
285 trial_pkg_names = []
285 286
286 287 if have_wx:
287 nose_packages.append('gui')
288
289 #nose_packages = ['config', 'utils'] # dbg
290 #trial_packages = [] # dbg
291
292 nose_packages = ['IPython.%s' % m for m in nose_packages ]
293 trial_packages = ['IPython.%s' % m for m in trial_packages ]
288 nose_pkg_names.append('gui')
294 289
295 # Make runners, most with nose
296 nose_testers = [IPTester(params=v) for v in nose_packages]
297 runners = zip(nose_packages, nose_testers)
298
299 290 # And add twisted ones if conditions are met
300 291 if have_zi and have_twisted and have_foolscap:
301 trial_testers = [IPTester('trial', params=v) for v in trial_packages]
302 runners.extend(zip(trial_packages, trial_testers))
303
292 # Note that we list the kernel here, though the bulk of it is
293 # twisted-based, because nose picks up doctests that twisted doesn't.
294 nose_pkg_names.append('kernel')
295 trial_pkg_names.append('kernel')
296
297 # For debugging this code, only load quick stuff
298 #nose_pkg_names = ['config', 'utils'] # dbg
299 #trial_pkg_names = [] # dbg
300
301 # Make fully qualified package names prepending 'IPython.' to our name lists
302 nose_packages = ['IPython.%s' % m for m in nose_pkg_names ]
303 trial_packages = ['IPython.%s' % m for m in trial_pkg_names ]
304
305 # Make runners
306 runners = [ (v, IPTester('iptest', params=v)) for v in nose_packages ]
307 runners.extend([ (v, IPTester('trial', params=v)) for v in trial_packages ])
308
304 309 return runners
305 310
306 311
@@ -11,6 +11,7 b' these things are also convenient when working at the command line.'
11 11 # Distributed under the terms of the BSD License. The full license is in
12 12 # the file COPYING, distributed as part of this software.
13 13 #*****************************************************************************
14 from __future__ import absolute_import
14 15
15 16 #****************************************************************************
16 17 # required modules from the Python standard library
@@ -45,7 +46,7 b' from IPython.external.Itpl import itpl,printpl'
45 46 from IPython.utils import platutils
46 47 from IPython.utils.generics import result_display
47 48 from IPython.external.path import path
48
49 from .baseutils import getoutputerror
49 50
50 51 #****************************************************************************
51 52 # Exceptions
@@ -194,16 +195,19 b' def warn(msg,level=2,exit_val=1):'
194 195 print >> Term.cerr,'Exiting.\n'
195 196 sys.exit(exit_val)
196 197
198
197 199 def info(msg):
198 200 """Equivalent to warn(msg,level=1)."""
199 201
200 202 warn(msg,level=1)
201 203
204
202 205 def error(msg):
203 206 """Equivalent to warn(msg,level=3)."""
204 207
205 208 warn(msg,level=3)
206 209
210
207 211 def fatal(msg,exit_val=1):
208 212 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
209 213
@@ -282,6 +286,7 b' except ImportError:'
282 286 This just returns clock() and zero."""
283 287 return time.clock(),0.0
284 288
289
285 290 def timings_out(reps,func,*args,**kw):
286 291 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
287 292
@@ -310,6 +315,7 b' def timings_out(reps,func,*args,**kw):'
310 315 av_time = tot_time / reps
311 316 return tot_time,av_time,out
312 317
318
313 319 def timings(reps,func,*args,**kw):
314 320 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
315 321
@@ -319,6 +325,7 b' def timings(reps,func,*args,**kw):'
319 325
320 326 return timings_out(reps,func,*args,**kw)[0:2]
321 327
328
322 329 def timing(func,*args,**kw):
323 330 """timing(func,*args,**kw) -> t_total
324 331
@@ -348,6 +355,7 b' def arg_split(s,posix=False):'
348 355 lex.whitespace_split = True
349 356 return list(lex)
350 357
358
351 359 def system(cmd,verbose=0,debug=0,header=''):
352 360 """Execute a system command, return its exit status.
353 361
@@ -369,6 +377,7 b" def system(cmd,verbose=0,debug=0,header=''):"
369 377 if not debug: stat = os.system(cmd)
370 378 return stat
371 379
380
372 381 def abbrev_cwd():
373 382 """ Return abbreviated version of cwd, e.g. d:mydir """
374 383 cwd = os.getcwd().replace('\\','/')
@@ -439,6 +448,7 b" if os.name in ('nt','dos'):"
439 448
440 449 shell.__doc__ = shell_ori.__doc__
441 450
451
442 452 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
443 453 """Dummy substitute for perl's backquotes.
444 454
@@ -468,45 +478,11 b" def getoutput(cmd,verbose=0,debug=0,header='',split=0):"
468 478 else:
469 479 return output
470 480
471 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
472 """Return (standard output,standard error) of executing cmd in a shell.
473
474 Accepts the same arguments as system(), plus:
475
476 - split(0): if true, each of stdout/err is returned as a list split on
477 newlines.
478
479 Note: a stateful version of this function is available through the
480 SystemExec class."""
481
482 if verbose or debug: print header+cmd
483 if not cmd:
484 if split:
485 return [],[]
486 else:
487 return '',''
488 if not debug:
489 p = subprocess.Popen(cmd, shell=True,
490 stdin=subprocess.PIPE,
491 stdout=subprocess.PIPE,
492 stderr=subprocess.PIPE,
493 close_fds=True)
494 pin, pout, perr = (p.stdin, p.stdout, p.stderr)
495
496 tout = pout.read().rstrip()
497 terr = perr.read().rstrip()
498 pin.close()
499 pout.close()
500 perr.close()
501 if split:
502 return tout.split('\n'),terr.split('\n')
503 else:
504 return tout,terr
505
506 481 # for compatibility with older naming conventions
507 482 xsys = system
508 483 bq = getoutput
509 484
485
510 486 class SystemExec:
511 487 """Access the system and getoutput functions through a stateful interface.
512 488
@@ -11,12 +11,25 b' to use these functions in platform agnostic fashion.'
11 11 # Distributed under the terms of the BSD License. The full license is in
12 12 # the file COPYING, distributed as part of this software.
13 13 #*****************************************************************************
14 #-----------------------------------------------------------------------------
15 # Imports
16 #-----------------------------------------------------------------------------
17 from __future__ import absolute_import
14 18
15 19 import sys
16 20 import os
17 21
22 from .baseutils import getoutputerror
23
24 #-----------------------------------------------------------------------------
25 # Globals
26 #-----------------------------------------------------------------------------
27
18 28 ignore_termtitle = True
19 29
30 #-----------------------------------------------------------------------------
31 # Functions
32 #-----------------------------------------------------------------------------
20 33
21 34 def _dummy_op(*a, **b):
22 35 """ A no-op function """
@@ -36,7 +49,7 b' else:'
36 49
37 50 def find_cmd(cmd):
38 51 """Find the full path to a command using which."""
39 return os.popen('which %s' % cmd).read().strip()
52 return getoutputerror('which %s' % cmd)[0]
40 53
41 54
42 55 def get_long_path_name(path):
General Comments 0
You need to be logged in to leave comments. Login now