forked from openSUSE/salt-toaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py.source
61 lines (45 loc) · 1.62 KB
/
conftest.py.source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
import glob
import pytest
from functools import partial
from fnmatch import fnmatch
def pytest_addoption(parser):
parser.addini(
"ignore_list",
type="args",
help="glob-style file patterns for Python test collect ignore",
default=[]
)
parser.addini(
"xfail_list",
type="args",
help="glob-style pytest node ids marked as expected failures",
default=[]
)
def pytest_ignore_collect(path, config):
return any(map(path.fnmatch, config.getini('ignore_list')))
def pytest_itemcollected(item):
matcher = partial(fnmatch, item.nodeid)
if any(map(matcher, item.config.getini('xfail_list'))):
item.addExpectedFailure(item.parent, None)
elif any(map(matcher, item.config.getini('ignore_list'))):
item.addSkip(item.parent, None)
def pytest_configure(config):
os.sys.path.extend(glob.glob(os.environ.get('SALT_TESTS')))
@pytest.fixture(scope="session")
def test_daemon(add_options, request):
from integration import TestDaemon
return TestDaemon(request.instance)
@pytest.fixture(scope="session")
def transplant_configs(test_daemon):
test_daemon.transplant_configs(transport='zeromq')
@pytest.fixture(scope="session")
def add_options(request):
from tests.runtests import SaltTestsuiteParser
parser = SaltTestsuiteParser([])
request.instance.options, args = parser.parse_args([])
@pytest.fixture(scope="session")
def salt_test_daemon(transplant_configs, test_daemon, request):
finalizer = partial(test_daemon.__exit__, None, None, None)
request.addfinalizer(finalizer)
test_daemon.__enter__()