16
16
from sentry_sdk .tracing import Transaction
17
17
18
18
19
- minimum_python_33 = pytest .mark .skipif (
20
- sys .version_info < (3 , 3 ), reason = "Profiling is only supported in Python >= 3.3"
21
- )
19
+ def requires_python_version (major , minor , reason = None ):
20
+ if reason is None :
21
+ reason = "Requires Python{}.{}" .format (major , minor )
22
+ return pytest .mark .skipif (sys .version_info < (major , minor ), reason = reason )
22
23
23
24
24
25
def process_test_sample (sample ):
25
26
return [(tid , (stack , stack )) for tid , stack in sample ]
26
27
27
28
28
- @minimum_python_33
29
+ @requires_python_version ( 3 , 3 )
29
30
def test_profiler_invalid_mode (teardown_profiling ):
30
31
with pytest .raises (ValueError ):
31
32
setup_profiler ({"_experiments" : {"profiler_mode" : "magic" }})
@@ -126,7 +127,9 @@ def static_method():
126
127
),
127
128
pytest .param (
128
129
GetFrame ().instance_method_wrapped ()(),
129
- "wrapped" ,
130
+ "wrapped"
131
+ if sys .version_info < (3 , 11 )
132
+ else "GetFrame.instance_method_wrapped.<locals>.wrapped" ,
130
133
id = "instance_method_wrapped" ,
131
134
),
132
135
pytest .param (
@@ -136,14 +139,15 @@ def static_method():
136
139
),
137
140
pytest .param (
138
141
GetFrame ().class_method_wrapped ()(),
139
- "wrapped" ,
142
+ "wrapped"
143
+ if sys .version_info < (3 , 11 )
144
+ else "GetFrame.class_method_wrapped.<locals>.wrapped" ,
140
145
id = "class_method_wrapped" ,
141
146
),
142
147
pytest .param (
143
148
GetFrame ().static_method (),
144
- "GetFrame.static_method" ,
149
+ "static_method" if sys . version_info < ( 3 , 11 ) else " GetFrame.static_method" ,
145
150
id = "static_method" ,
146
- marks = pytest .mark .skip (reason = "unsupported" ),
147
151
),
148
152
pytest .param (
149
153
GetFrame ().inherited_instance_method (),
@@ -152,7 +156,9 @@ def static_method():
152
156
),
153
157
pytest .param (
154
158
GetFrame ().inherited_instance_method_wrapped ()(),
155
- "wrapped" ,
159
+ "wrapped"
160
+ if sys .version_info < (3 , 11 )
161
+ else "GetFrameBase.inherited_instance_method_wrapped.<locals>.wrapped" ,
156
162
id = "instance_method_wrapped" ,
157
163
),
158
164
pytest .param (
@@ -162,14 +168,17 @@ def static_method():
162
168
),
163
169
pytest .param (
164
170
GetFrame ().inherited_class_method_wrapped ()(),
165
- "wrapped" ,
171
+ "wrapped"
172
+ if sys .version_info < (3 , 11 )
173
+ else "GetFrameBase.inherited_class_method_wrapped.<locals>.wrapped" ,
166
174
id = "inherited_class_method_wrapped" ,
167
175
),
168
176
pytest .param (
169
177
GetFrame ().inherited_static_method (),
170
- "GetFrameBase.static_method" ,
178
+ "inherited_static_method"
179
+ if sys .version_info < (3 , 11 )
180
+ else "GetFrameBase.inherited_static_method" ,
171
181
id = "inherited_static_method" ,
172
- marks = pytest .mark .skip (reason = "unsupported" ),
173
182
),
174
183
],
175
184
)
@@ -255,7 +264,7 @@ def get_scheduler_threads(scheduler):
255
264
return [thread for thread in threading .enumerate () if thread .name == scheduler .name ]
256
265
257
266
258
- @minimum_python_33
267
+ @requires_python_version ( 3 , 3 )
259
268
@pytest .mark .parametrize (
260
269
("scheduler_class" ,),
261
270
[pytest .param (SleepScheduler , id = "sleep scheduler" )],
0 commit comments