Skip to content

Commit ed7de36

Browse files
author
Codeslayer666
committed
refactor the run integration tests flag
1 parent 5dbd6ed commit ed7de36

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

test/test_integration/test_integration_test.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,24 @@
2121
PASSWORD = os.environ.get('UPCLOUD_API_PASSWD')
2222

2323

24-
integration_test = pytest.mark.skipif(
25-
not getattr(pytest, "--integration-tests", None),
26-
reason='need --integration-tests option to run'
27-
)
24+
def pytest_addoption(parser):
25+
parser.addoption(
26+
"--integration-tests", action="store_true", default=False, help="run integration tests"
27+
)
28+
29+
30+
def pytest_configure(config):
31+
config.addinivalue_line("markers", "interagtion: mark test as integration")
32+
33+
34+
def pytest_collection_modifyitems(config, items):
35+
if config.getoption("--integration-tests"):
36+
# --integration-tests given in cli: do not skip integration tests
37+
return
38+
integration_tests = pytest.mark.skip(reason="need --integration-tests option to run")
39+
for item in items:
40+
if "integration_test" in item.keywords:
41+
item.add_marker(integration_tests)
2842

2943

3044
# globals to store created resources so we can cleanup after tests
@@ -42,7 +56,7 @@ def delete_tag(tag):
4256
tag.destroy()
4357

4458

45-
@integration_test
59+
@pytest.mark.integration_test
4660
def teardown_module(module):
4761
manager = CloudManager(USERNAME, PASSWORD, timeout=160)
4862

@@ -61,7 +75,7 @@ def teardown_module(module):
6175
manager.delete_tag(tag)
6276

6377

64-
@integration_test
78+
@pytest.mark.integration_test
6579
def test_infra_ops():
6680
global CREATED_SERVERS
6781
global CREATED_TAGS

0 commit comments

Comments
 (0)