##// END OF EJS Templates
Merge pull request #4632 from takluyver/testfunc...
Paul Ivanov -
r13746:2d6b9e25 merge
parent child Browse files
Show More
@@ -13,16 +13,25
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
14
15 # User-level entry point for testing
15 # User-level entry point for testing
16 def test(all=False):
16 def test(**kwargs):
17 """Run the entire IPython test suite.
17 """Run the entire IPython test suite.
18
18
19 For fine-grained control, you should use the :file:`iptest` script supplied
19 Any of the options for run_iptestall() may be passed as keyword arguments.
20 with the IPython installation."""
20
21 For example::
22
23 IPython.test(testgroups=['lib', 'config', 'utils'], fast=2)
24
25 will run those three sections of the test suite, using two processes.
26 """
21
27
22 # Do the import internally, so that this function doesn't increase total
28 # Do the import internally, so that this function doesn't increase total
23 # import time
29 # import time
24 from .iptest import run_iptestall
30 from .iptestcontroller import run_iptestall, default_options
25 run_iptestall(inc_slow=all)
31 options = default_options()
32 for name, val in kwargs.items():
33 setattr(options, name, val)
34 run_iptestall(options)
26
35
27 # So nose doesn't try to run this as a test itself and we end up with an
36 # So nose doesn't try to run this as a test itself and we end up with an
28 # infinite test loop
37 # infinite test loop
@@ -456,6 +456,27 def run_iptestall(options):
456 # Ensure that our exit code indicates failure
456 # Ensure that our exit code indicates failure
457 sys.exit(1)
457 sys.exit(1)
458
458
459 argparser = argparse.ArgumentParser(description='Run IPython test suite')
460 argparser.add_argument('testgroups', nargs='*',
461 help='Run specified groups of tests. If omitted, run '
462 'all tests.')
463 argparser.add_argument('--all', action='store_true',
464 help='Include slow tests not run by default.')
465 argparser.add_argument('-j', '--fast', nargs='?', const=None, default=1, type=int,
466 help='Run test sections in parallel.')
467 argparser.add_argument('--xunit', action='store_true',
468 help='Produce Xunit XML results')
469 argparser.add_argument('--coverage', nargs='?', const=True, default=False,
470 help="Measure test coverage. Specify 'html' or "
471 "'xml' to get reports.")
472
473 def default_options():
474 """Get an argparse Namespace object with the default arguments, to pass to
475 :func:`run_iptestall`.
476 """
477 options = argparser.parse_args([])
478 options.extra_args = []
479 return options
459
480
460 def main():
481 def main():
461 # Arguments after -- should be passed through to nose. Argparse treats
482 # Arguments after -- should be passed through to nose. Argparse treats
@@ -470,21 +491,7 def main():
470 to_parse = sys.argv[1:ix]
491 to_parse = sys.argv[1:ix]
471 extra_args = sys.argv[ix+1:]
492 extra_args = sys.argv[ix+1:]
472
493
473 parser = argparse.ArgumentParser(description='Run IPython test suite')
494 options = argparser.parse_args(to_parse)
474 parser.add_argument('testgroups', nargs='*',
475 help='Run specified groups of tests. If omitted, run '
476 'all tests.')
477 parser.add_argument('--all', action='store_true',
478 help='Include slow tests not run by default.')
479 parser.add_argument('-j', '--fast', nargs='?', const=None, default=1, type=int,
480 help='Run test sections in parallel.')
481 parser.add_argument('--xunit', action='store_true',
482 help='Produce Xunit XML results')
483 parser.add_argument('--coverage', nargs='?', const=True, default=False,
484 help="Measure test coverage. Specify 'html' or "
485 "'xml' to get reports.")
486
487 options = parser.parse_args(to_parse)
488 options.extra_args = extra_args
495 options.extra_args = extra_args
489
496
490 run_iptestall(options)
497 run_iptestall(options)
General Comments 0
You need to be logged in to leave comments. Login now