##// END OF EJS Templates
Restore the ability to run tests from a function.
Thomas Kluyver -
Show More
@@ -21,8 +21,10 b' def test(all=False):'
21
21
22 # Do the import internally, so that this function doesn't increase total
22 # Do the import internally, so that this function doesn't increase total
23 # import time
23 # import time
24 from .iptest import run_iptestall
24 from .iptestcontroller import run_iptestall, default_options
25 run_iptestall(inc_slow=all)
25 options = default_options()
26 options.all = all
27 run_iptestall(options)
26
28
27 # So nose doesn't try to run this as a test itself and we end up with an
29 # So nose doesn't try to run this as a test itself and we end up with an
28 # infinite test loop
30 # infinite test loop
@@ -456,6 +456,27 b' 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 b' 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