-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathconftest.py
95 lines (75 loc) · 2.89 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
import sys
from pathlib import Path
import pytest
from .network import setup_cronos, setup_custom_cronos, setup_geth
dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(dir + "/protobuf")
def pytest_configure(config):
config.addinivalue_line("markers", "unmarked: fallback mark for unmarked tests")
config.addinivalue_line("markers", "slow: marks tests as slow")
config.addinivalue_line("markers", "gravity: gravity bridge test cases")
config.addinivalue_line("markers", "ica: marks ica tests")
config.addinivalue_line("markers", "upgrade: marks upgrade tests")
config.addinivalue_line("markers", "ibc: marks default ibc tests")
config.addinivalue_line("markers", "ibc_rly_evm: marks ibc_rly_evm tests")
config.addinivalue_line("markers", "ibc_rly_gas: marks ibc relayer gas tests")
config.addinivalue_line("markers", "ibc_timeout: marks ibc timeout tests")
config.addinivalue_line("markers", "ibc_update_client: marks ibc updateclient test")
config.addinivalue_line("markers", "gov: marks gov related tests")
config.addinivalue_line("markers", "gas: marks gas related tests")
def pytest_collection_modifyitems(items, config):
for item in items:
if not any(item.iter_markers()):
item.add_marker("unmarked")
@pytest.fixture(scope="session")
def suspend_capture(pytestconfig):
"""
used to pause in testing
Example:
```
def test_simple(suspend_capture):
with suspend_capture:
# read user input
print(input())
```
"""
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()
@pytest.fixture(scope="session", params=[True])
def cronos(request, tmp_path_factory):
enable_indexer = request.param
if enable_indexer:
path = tmp_path_factory.mktemp("indexer")
yield from setup_custom_cronos(
path, 27000, Path(__file__).parent / "configs/enable-indexer.jsonnet"
)
else:
path = tmp_path_factory.mktemp("cronos")
yield from setup_cronos(path, 26650)
@pytest.fixture(scope="session")
def geth(tmp_path_factory):
path = tmp_path_factory.mktemp("geth")
yield from setup_geth(path, 8545)
@pytest.fixture(scope="session", params=["cronos", "geth", "cronos-ws"])
def cluster(request, cronos, geth):
"""
run on both cronos and geth
"""
provider = request.param
if provider == "cronos":
yield cronos
elif provider == "geth":
yield geth
elif provider == "cronos-ws":
cronos_ws = cronos.copy()
cronos_ws.use_websocket()
yield cronos_ws
else:
raise NotImplementedError