File tree 2 files changed +13
-4
lines changed 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change
1
+ Fixed a possible ``KeyError `` crash on PyPy during collection of tests involving higher-scoped parameters.
Original file line number Diff line number Diff line change @@ -278,10 +278,18 @@ def reorder_items_atscope(
278
278
for other_scope in HIGH_SCOPES :
279
279
other_scoped_items_by_argkey = items_by_argkey [other_scope ]
280
280
for argkey in argkeys_by_item [other_scope ].get (i , ()):
281
- other_scoped_items_by_argkey [argkey ][i ] = None
282
- other_scoped_items_by_argkey [argkey ].move_to_end (
283
- i , last = False
284
- )
281
+ argkey_dict = other_scoped_items_by_argkey [argkey ]
282
+ if not hasattr (sys , "pypy_version_info" ):
283
+ argkey_dict [i ] = None
284
+ argkey_dict .move_to_end (i , last = False )
285
+ else :
286
+ # Work around a bug in PyPy:
287
+ # https://github.com/pypy/pypy/issues/5257
288
+ # https://github.com/pytest-dev/pytest/issues/13312
289
+ bkp = argkey_dict .copy ()
290
+ argkey_dict .clear ()
291
+ argkey_dict [i ] = None
292
+ argkey_dict .update (bkp )
285
293
break
286
294
if no_argkey_items :
287
295
reordered_no_argkey_items = reorder_items_atscope (
You can’t perform that action at this time.
0 commit comments