[SciPy-Dev] Run just the test functions that match a given pattern?

Matti Picus matti.picus at gmail.com
Sun Apr 19 11:23:03 EDT 2020


On 19/4/20 6:06 pm, Warren Weckesser wrote:
> With runtests.py, we can run the tests for a specific module (e.g. `-s
> stats`), a specific file (e.g. `-t scipy.stats.tests.test_stats`), or
> a specific class or function within a file (e.g. `-s
> scipy.stats.tests.test_stats::TestCorrPearsonr`, `-s
> scipy.stats.tests.test_stats::test_kendalltau`).  Is there a way to
> run the tests whose names match a given pattern?  For example, I'd
> like to use the pattern `*ttest_rel*` to run any test that has
> `ttest_rel` in its name.
>
> I can hack this by adding the line
>
>      python_functions = *ttest_rel*
>
> to pytest.ini, and then comment out that line when I want to run a
> larger set of tests, but it would be nice if a pattern could be given
> in the command line.
>
> Warren


I think this is a documentation issue. Since scipy uses pytest under the 
hood to actually run the tests, any extra arguments after `--` are 
passed to pytest, so you should be able to use `python runtest.py -- -k 
"*ttest_rel*' which will use pytest's regex test chooser. At least that 
is the way it works on numpy ...


Matti



More information about the SciPy-Dev mailing list