@@ -44,10 +44,16 @@ def pytest_configure(config: pytest.Config) -> None:
4444def pytest_collection_modifyitems (
4545 config : pytest .Config , items : list [pytest .Item ]
4646) -> None :
47- """Remove non-repricing tests when --fixed-opcode-count is specified."""
47+ """Filter tests based on repricing marker"""
48+ gas_benchmark_value = config .getoption ("gas_benchmark_value" )
4849 fixed_opcode_count = config .getoption ("fixed_opcode_count" )
49- if not fixed_opcode_count :
50- # If --fixed-opcode-count is not specified, don't filter anything
50+
51+ if not gas_benchmark_value and not fixed_opcode_count :
52+ return
53+
54+ # Check if -m repricing marker filter was specified
55+ markexpr = config .getoption ("markexpr" , "" )
56+ if "repricing" not in markexpr or "not repricing" in markexpr :
5157 return
5258
5359 filtered = []
@@ -105,27 +111,22 @@ def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
105111 )
106112
107113 if "fixed_opcode_count" in metafunc .fixturenames :
108- # Only parametrize if test has repricing marker
109- has_repricing = (
110- metafunc .definition .get_closest_marker ("repricing" ) is not None
111- )
112- if has_repricing :
113- if fixed_opcode_counts :
114- opcode_counts = [
115- int (x .strip ()) for x in fixed_opcode_counts .split ("," )
116- ]
117- opcode_count_parameters = [
118- pytest .param (
119- opcode_count ,
120- id = f"opcount_{ opcode_count } K" ,
121- )
122- for opcode_count in opcode_counts
123- ]
124- metafunc .parametrize (
125- "fixed_opcode_count" ,
126- opcode_count_parameters ,
127- scope = "function" ,
114+ if fixed_opcode_counts :
115+ opcode_counts = [
116+ int (x .strip ()) for x in fixed_opcode_counts .split ("," )
117+ ]
118+ opcode_count_parameters = [
119+ pytest .param (
120+ opcode_count ,
121+ id = f"opcount_{ opcode_count } K" ,
128122 )
123+ for opcode_count in opcode_counts
124+ ]
125+ metafunc .parametrize (
126+ "fixed_opcode_count" ,
127+ opcode_count_parameters ,
128+ scope = "function" ,
129+ )
129130
130131
131132@pytest .fixture (scope = "function" )
0 commit comments