@@ -166,7 +166,8 @@ class EMOJI:
166166 "dev.py test" : [
167167 {
168168 "name" : "Options" ,
169- "options" : ["--help" , "--verbose" , "--parallel" , "--coverage" ],
169+ "options" : ["--help" , "--verbose" , "--parallel" , "--coverage" ,
170+ "--durations" ],
170171 },
171172 {
172173 "name" : "Options: test selection" ,
@@ -402,7 +403,7 @@ class Build(Task):
402403 debug = Option (
403404 ['--debug' , '-d' ], default = False , is_flag = True , help = "Debug build" )
404405 parallel = Option (
405- ['--parallel' , '-j' ], default = 1 , metavar = 'PARALLEL ' ,
406+ ['--parallel' , '-j' ], default = 1 , metavar = 'N_JOBS ' ,
406407 help = "Number of parallel jobs for build and testing" )
407408 show_build_log = Option (
408409 ['--show-build-log' ], default = False , is_flag = True ,
@@ -627,7 +628,8 @@ class Test(Task):
627628
628629 $ python dev.py test -s {SAMPLE_SUBMODULE}
629630 $ python dev.py test -t scipy.optimize.tests.test_minimize_constrained
630- $ python dev.py test -s stats -- --tb=line
631+ $ python dev.py test -s cluster -m full --durations 20
632+ $ python dev.py test -s stats -- --tb=line # `--` passes next args to pytest
631633 ```
632634 """
633635 ctx = CONTEXT
@@ -638,11 +640,15 @@ class Test(Task):
638640 # removed doctests as currently not supported by _lib/_testutils.py
639641 # doctests = Option(['--doctests'], default=False)
640642 coverage = Option (
641- ['--coverage' ], default = False , is_flag = True ,
643+ ['--coverage' , '-c' ], default = False , is_flag = True ,
642644 help = ("report coverage of project code. "
643645 "HTML output goes under build/coverage" ))
646+ durations = Option (
647+ ['--durations' , '-d' ], default = None , metavar = "NUM_TESTS" ,
648+ help = "Show timing for the given number of slowest tests"
649+ )
644650 submodule = Option (
645- ['--submodule' , '-s' ], default = None , metavar = 'SUBMODULE ' ,
651+ ['--submodule' , '-s' ], default = None , metavar = 'MODULE_NAME ' ,
646652 help = "Submodule whose tests to run (cluster, constants, ...)" )
647653 tests = Option (
648654 ['--tests' , '-t' ], default = None , multiple = True , metavar = 'TESTS' ,
@@ -652,11 +658,13 @@ class Test(Task):
652658 help = ("'fast', 'full', or something that could be passed to "
653659 "`pytest -m` as a marker expression" ))
654660 parallel = Option (
655- ['--parallel' , '-j' ], default = 1 , metavar = 'PARALLEL ' ,
661+ ['--parallel' , '-j' ], default = 1 , metavar = 'N_JOBS ' ,
656662 help = "Number of parallel jobs for testing"
657663 )
664+ # Argument can't have `help=`; used to consume all of `-- arg1 arg2 arg3`
658665 pytest_args = Argument (
659- ['pytest_args' ], nargs = - 1 , metavar = 'PYTEST-ARGS' , required = False )
666+ ['pytest_args' ], nargs = - 1 , metavar = 'PYTEST-ARGS' , required = False
667+ )
660668
661669 TASK_META = {
662670 'task_dep' : ['build' ],
@@ -682,6 +690,9 @@ def scipy_tests(cls, args, pytest_args):
682690 shutil .copyfile (dirs .root / '.coveragerc' ,
683691 dirs .site / '.coveragerc' )
684692
693+ if args .durations :
694+ extra_argv += ['--durations' , args .durations ]
695+
685696 # convert options to test selection
686697 if args .submodule :
687698 tests = [PROJECT_MODULE + "." + args .submodule ]
@@ -944,7 +955,7 @@ class Doc(Task):
944955 help = 'List doc targets' ,
945956 )
946957 parallel = Option (
947- ['--parallel' , '-j' ], default = 1 , metavar = 'PARALLEL ' ,
958+ ['--parallel' , '-j' ], default = 1 , metavar = 'N_JOBS ' ,
948959 help = "Number of parallel jobs"
949960 )
950961
0 commit comments