File tree 4 files changed +29
-2
lines changed 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import pytest
5
5
6
+
7
+ def pytest_addoption (parser ):
8
+ parser .addoption (
9
+ "--run-integration-tests" , action = "store_true" , help = ("Run integration tests." )
10
+ )
11
+
12
+
6
13
if sys .gettrace ():
7
14
8
15
@pytest .fixture (autouse = True )
@@ -17,6 +24,23 @@ def restore_tracing():
17
24
sys .settrace (orig_trace )
18
25
19
26
27
+ @pytest .hookimpl
28
+ def pytest_runtest_setup (item ):
29
+ mark = "integration"
30
+ option = "--run-integration-tests"
31
+ if mark not in item .keywords or item .config .getoption (option ):
32
+ return
33
+
34
+ # Run the test anyway if it was provided via its nodeid as arg.
35
+ # NOTE: do not use startswith: should skip
36
+ # "tests/test_foo.py::test_bar" with
37
+ # "tests/test_foo.py" in invocation args.
38
+ if any (item .nodeid == arg for arg in item .config .invocation_params .args ):
39
+ return
40
+
41
+ pytest .skip ("Not running {} test (use {})" .format (mark , option ))
42
+
43
+
20
44
@pytest .hookimpl (hookwrapper = True , tryfirst = True )
21
45
def pytest_collection_modifyitems (config , items ):
22
46
"""Prefer faster tests.
Original file line number Diff line number Diff line change 5
5
import _pytest
6
6
import pytest
7
7
8
+ pytestmark = [pytest .mark .integration , pytest .mark .slow ]
9
+
8
10
9
11
def _modules ():
10
12
return sorted (
@@ -15,7 +17,6 @@ def _modules():
15
17
)
16
18
17
19
18
- @pytest .mark .slow
19
20
@pytest .mark .parametrize ("module" , _modules ())
20
21
def test_no_warnings (module ):
21
22
# fmt: off
Original file line number Diff line number Diff line change 6
6
import _pytest
7
7
import pytest
8
8
9
- pytestmark = pytest .mark .slow
9
+ pytestmark = [ pytest .mark .integration , pytest . mark . slow ]
10
10
11
11
MODSET = [
12
12
x
Original file line number Diff line number Diff line change @@ -163,6 +163,8 @@ markers =
163
163
baz
164
164
# conftest.py reorders tests moving slow ones to the end of the list
165
165
slow
166
+ # tests to be run only on CI (slow, unlikely to be a problem normally)
167
+ integration
166
168
# experimental mark for all tests using pexpect
167
169
uses_pexpect
168
170
You can’t perform that action at this time.
0 commit comments