File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 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 @@ -286,10 +286,18 @@ def reorder_items_atscope(
286286 for other_scope in HIGH_SCOPES :
287287 other_scoped_items_by_argkey = items_by_argkey [other_scope ]
288288 for argkey in argkeys_by_item [other_scope ].get (i , ()):
289- other_scoped_items_by_argkey [argkey ][i ] = None
290- other_scoped_items_by_argkey [argkey ].move_to_end (
291- i , last = False
292- )
289+ argkey_dict = other_scoped_items_by_argkey [argkey ]
290+ if not hasattr (sys , "pypy_version_info" ):
291+ argkey_dict [i ] = None
292+ argkey_dict .move_to_end (i , last = False )
293+ else :
294+ # Work around a bug in PyPy:
295+ # https://github.com/pypy/pypy/issues/5257
296+ # https://github.com/pytest-dev/pytest/issues/13312
297+ bkp = argkey_dict .copy ()
298+ argkey_dict .clear ()
299+ argkey_dict [i ] = None
300+ argkey_dict .update (bkp )
293301 break
294302 if no_argkey_items :
295303 reordered_no_argkey_items = reorder_items_atscope (
You can’t perform that action at this time.
0 commit comments