-
Notifications
You must be signed in to change notification settings - Fork 351
/
conftest.py
51 lines (37 loc) · 1.61 KB
/
conftest.py
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
import re
from pathlib import Path
import pytest
from .utils import cluster_fixture
def pytest_configure(config):
config.addinivalue_line("markers", "slow: marks tests as slow")
config.addinivalue_line("markers", "ledger: marks tests as ledger hardware test")
config.addinivalue_line("markers", "grpc: marks grpc tests")
config.addinivalue_line("markers", "upgrade: marks upgrade tests")
config.addinivalue_line("markers", "normal: marks normal tests")
config.addinivalue_line("markers", "ibc: marks ibc tests")
config.addinivalue_line("markers", "byzantine: marks byzantine tests")
config.addinivalue_line("markers", "gov: marks gov tests")
config.addinivalue_line("markers", "solomachine: marks solomachine tests")
@pytest.fixture(scope="session")
def worker_index(worker_id):
match = re.search(r"\d+", worker_id)
return int(match[0]) if match is not None else 0
@pytest.fixture(scope="session")
def cluster(worker_index, pytestconfig, tmp_path_factory):
"default cluster fixture"
yield from cluster_fixture(
Path(__file__).parent / "configs/default.jsonnet",
worker_index,
tmp_path_factory.mktemp("data"),
)
@pytest.fixture(scope="session")
def suspend_capture(pytestconfig):
"used for pause in testing"
class SuspendGuard:
def __init__(self):
self.capmanager = pytestconfig.pluginmanager.getplugin("capturemanager")
def __enter__(self):
self.capmanager.suspend_global_capture(in_=True)
def __exit__(self, _1, _2, _3):
self.capmanager.resume_global_capture()
yield SuspendGuard()