Commit d47cc39 1 parent 6a62b0c commit d47cc39 Copy full SHA for d47cc39
File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -22,3 +22,28 @@ def pytest_report_header(config):
22
22
f"PythonQwt { qwt .__version__ } [closest Qwt version: { qwt .QWT_VERSION_STR } ]" ,
23
23
f"{ qtpy .API_NAME } { qtbindings_version } [Qt version: { qtpy .QT_VERSION } ]" ,
24
24
]
25
+
26
+
27
+ def pytest_addoption (parser ):
28
+ """Add custom command line options to pytest."""
29
+ # See this StackOverflow answer for more information: https://t.ly/9anqz
30
+ parser .addoption (
31
+ "--repeat" , action = "store" , help = "Number of times to repeat each test"
32
+ )
33
+
34
+
35
+ def pytest_generate_tests (metafunc ):
36
+ """Generate tests for the given metafunc."""
37
+ # See this StackOverflow answer for more information: https://t.ly/9anqz
38
+ if metafunc .config .option .repeat is not None :
39
+ count = int (metafunc .config .option .repeat )
40
+
41
+ # We're going to duplicate these tests by parametrizing them,
42
+ # which requires that each test has a fixture to accept the parameter.
43
+ # We can add a new fixture like so:
44
+ metafunc .fixturenames .append ("tmp_ct" )
45
+
46
+ # Now we parametrize. This is what happens when we do e.g.,
47
+ # @pytest.mark.parametrize('tmp_ct', range(count))
48
+ # def test_foo(): pass
49
+ metafunc .parametrize ("tmp_ct" , range (count ))
You can’t perform that action at this time.
0 commit comments