Description
Feature or enhancement
Currently you can use --match
and --ignore
options for positive and negative filtering of test cases by name. But negative patterns always win. So you can select a class of tests and then exclude some tests from it, but you cannot exclude a class of tests except some tests.
Many programs that have similar options (can also be named --include
/--exclude
) use different algorithm. They apply rules in the order, and the last rule wins. I propose to implement this in Python regrtests too. Examples:
Run FileTests
tests in test_os
, excluding test_write
:
./python -m test test_os -m FileTests -i test_write
Run all tests in test_os
, excluding FileTests
tests, but including test_write
:
./python -m test test_os -i FileTests -m test_write
And, of course, any combinations are valid. This applies also to options that read patterns from files: --matchfile
and --ignorefile
. The implementation is actually somewhat simpler than the current one.
Linked PRs
- gh-110918: regrtest: allow to intermix --match and --ignore options #110919
- [3.12] gh-110918: regrtest: allow to intermix --match and --ignore options (GH-110919) #111167
- [3.11] gh-110918: regrtest: allow to intermix --match and --ignore options (GH-110919) #111168
- gh-110918: Fix side effects of regrtest test_match_tests() #116718
- [3.12] gh-110918: Fix side effects of regrtest test_match_tests() (GH-116718) #116726
- [3.11] gh-110918: Fix side effects of regrtest test_match_tests() (GH-116718) #116727