1
- # pytest-regex
1
+ pytest-regex
2
+ ------------
2
3
3
- ## Use Python Standard Library Regular Expressions to Specify Tests to Run
4
+ Use Python Standard Library Regular Expressions to Specify Tests to Run
5
+ -----------------------------------------------------------------------
4
6
5
7
After installing locally with i.e., ` python -m pip install . ` you can
6
8
compare it with more conventional test selection techniques as follows.
@@ -13,37 +15,34 @@ built-in `-k` flag:
13
15
14
16
This runs a bunch of tests with string matches as you might expect:
15
17
16
- ```
17
- scipy/io/tests/test_idl.py::TestArrayDimensions::test_3d PASSED
18
- scipy/io/tests/test_idl.py::TestPointerArray::test_3d PASSED
19
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestBoxBoundariesIntersections::test_3d_box_constraints PASSED
20
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestBoxBoundariesIntersections::test_3d_box_constraints_entire_line PASSED
21
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestModifiedDogleg::test_3d_example PASSED
22
- scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array PASSED
23
- scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_type_tuple PASSED
24
- scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_0 PASSED
25
- scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_1 PASSED
26
- scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_2 PASSED
27
- scipy/stats/tests/test_stats.py::TestFOneWay::test_3d_inputs PASSED
28
- ```
18
+ scipy/io/tests/test_idl.py::TestArrayDimensions::test_3d PASSED
19
+ scipy/io/tests/test_idl.py::TestPointerArray::test_3d PASSED
20
+ scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestBoxBoundariesIntersections::test_3d_box_constraints PASSED
21
+ scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestBoxBoundariesIntersections::test_3d_box_constraints_entire_line PASSED
22
+ scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestModifiedDogleg::test_3d_example PASSED
23
+ scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array PASSED
24
+ scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_type_tuple PASSED
25
+ scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_0 PASSED
26
+ scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_1 PASSED
27
+ scipy/stats/tests/test_stats.py::TestGeometricStandardDeviation::test_3d_array_axis_2 PASSED
28
+ scipy/stats/tests/test_stats.py::TestFOneWay::test_3d_inputs PASSED
29
29
30
30
What if you want to run only tests with an exact match to ` test_3d ` or
31
31
` test_3d_example ` ?
32
32
33
33
Try ` pytest-regex ` with:
34
- ` python dev.py test -- -v --regex "(.*test_3d$|.*test_3d_example$)" `
34
+ python dev.py test -- -v --regex "(.* test_3d$|.* test_3d_example$)"
35
35
36
36
37
- ```
38
- scipy/io/tests/test_idl.py::TestArrayDimensions::test_3d PASSED
39
- scipy/io/tests/test_idl.py::TestPointerArray::test_3d PASSED
40
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestModifiedDogleg::test_3d_example PASSED
41
- ```
37
+ scipy/io/tests/test_idl.py::TestArrayDimensions::test_3d PASSED
38
+ scipy/io/tests/test_idl.py::TestPointerArray::test_3d PASSED
39
+ scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py::TestModifiedDogleg::test_3d_example PASSED
42
40
43
41
This does what we want, and is probably more concise than the ` -k ` alternative. In fact,
44
42
I'm not entirely sure how one would do this with ` -k ` in its current form.
45
43
46
- ## How it Works
44
+ How it Works
45
+ ------------
47
46
48
47
` pytest-regex ` simply passes the Python regular expression through
49
48
to the list of node ids, where a node id is structured as follows:
0 commit comments