Skip to content

Commit 0dc6ae1

Browse files
feat(orc-372): add stricter marks checking
1 parent e5f44e6 commit 0dc6ae1

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tests/conftest.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
INTEGRATION_MARKER = 'integration'
2828
MAINNET_MARKER = 'mainnet'
2929
TESTNET_MARKER = 'testnet'
30+
FORK_MARKER = 'fork'
31+
32+
INTEGRATION_TESTS_MODIFICATORS_MARKERS = {
33+
MAINNET_MARKER,
34+
TESTNET_MARKER,
35+
FORK_MARKER,
36+
}
3037

3138
DUMMY_ADDRESS = "0x0000000000000000000000000000000000000000"
3239

@@ -40,14 +47,19 @@
4047
def check_test_marks_compatibility(request):
4148
all_test_markers = {x.name for x in request.node.iter_markers()}
4249

43-
if not all_test_markers:
44-
pytest.fail('Test must be marked.')
50+
if not all_test_markers or not {UNIT_MARKER, INTEGRATION_MARKER} & all_test_markers:
51+
pytest.fail('Test must be marked with at least one marker, e.g. @pytest.mark.unit or @pytest.mark.integration.')
4552

46-
elif UNIT_MARKER in all_test_markers and {MAINNET_MARKER, TESTNET_MARKER, INTEGRATION_MARKER} & all_test_markers:
53+
elif (
54+
UNIT_MARKER in all_test_markers
55+
and {INTEGRATION_MARKER}.union(INTEGRATION_TESTS_MODIFICATORS_MARKERS) & all_test_markers
56+
):
4757
pytest.fail('Test can not be both unit and integration at the same time.')
4858

49-
elif {MAINNET_MARKER, TESTNET_MARKER} & all_test_markers and INTEGRATION_MARKER not in all_test_markers:
50-
pytest.fail('Test can not be run on mainnet or testnet without integration marker.')
59+
elif INTEGRATION_TESTS_MODIFICATORS_MARKERS & all_test_markers and INTEGRATION_MARKER not in all_test_markers:
60+
pytest.fail(
61+
f'Test can not be run with {INTEGRATION_TESTS_MODIFICATORS_MARKERS} markers without @pytest.mark.integration.'
62+
)
5163

5264

5365
@pytest.fixture(autouse=True)

0 commit comments

Comments
 (0)