8
8
9
9
import configparser
10
10
import datetime
11
+ import inspect
11
12
import os
12
13
import warnings
13
14
from enum import Enum
@@ -1121,11 +1122,9 @@ def pytest_collection_modifyitems(
1121
1122
parametrization occurs in the forks plugin.
1122
1123
1123
1124
Also dynamically adds custom markers to tests based on their parameters (e.g.,
1124
- `blockchain_test_sync_only` for tests that have `verify_sync=True ` in their
1125
+ `blockchain_test_sync_only` for tests that have `verify_sync` in their
1125
1126
`blockchain_test` parameters).
1126
1127
"""
1127
- import inspect
1128
-
1129
1128
items_for_removal = []
1130
1129
for i , item in enumerate (items ):
1131
1130
params : Dict [str , Any ] | None = None
@@ -1146,27 +1145,14 @@ def pytest_collection_modifyitems(
1146
1145
items_for_removal .append (i )
1147
1146
continue
1148
1147
1149
- # Check if test has ``verify_sync=True`` and add marker if it does
1150
- # This needs to happen before we check ``discard_fixture_format_by_marks``
1151
- if hasattr (item , "function" ):
1152
- try :
1153
- test_func = item .function
1154
- source = inspect .getsource (test_func )
1155
- if "verify_sync=True" in source :
1156
- # Add the marker so pytest can filter it with `-m`
1157
- item .add_marker (pytest .mark .blockchain_test_sync_only )
1158
- except Exception :
1159
- pass # If we can't inspect, just continue
1148
+ # Add ``blockchain_test_sync_only`` marker to blockchain fixture if it uses
1149
+ # ``verify_sync``
1150
+ if fixture_format == BlockchainEngineSyncFixture and isinstance (item , pytest .Function ):
1151
+ source = inspect .getsource (item .function )
1152
+ if "verify_sync" in source :
1153
+ item .add_marker (pytest .mark .blockchain_test_sync_only )
1160
1154
1161
1155
markers = list (item .iter_markers ())
1162
- # Check for ``-m blockchain_test_sync_only`` and only fill sync tests
1163
- if (
1164
- config .getoption ("-m" ) == "blockchain_test_sync_only"
1165
- and "blockchain_test_sync_only" in [m .name for m in markers ]
1166
- and fixture_format != BlockchainEngineSyncFixture
1167
- ):
1168
- items_for_removal .append (i )
1169
- continue
1170
1156
if spec_type .discard_fixture_format_by_marks (fixture_format , fork , markers ):
1171
1157
items_for_removal .append (i )
1172
1158
continue
0 commit comments