mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
Fix pytest crashes with hypothesis and pydantic (#3727)
Pytest (sometimes?) crashes when it is invoked with `-vv` and pydantic and hypthesis are installed. This is because `_registered(typ)` modifies `_DEFINED_TYPES` while it is being iterated: ``` INTERNALERROR> File ".../lib/python3.9/site-packages/pydantic/_hypothesis_plugin.py", line 361, in <module> INTERNALERROR> for typ in pydantic.types._DEFINED_TYPES: INTERNALERROR> File ".../lib/python3.9/_weakrefset.py", line 65, in __iter__ INTERNALERROR> for itemref in self.data: INTERNALERROR> RuntimeError: Set changed size during iteration ```
This commit is contained in:
@@ -358,7 +358,7 @@ def resolve_constr(cls): # type: ignore[no-untyped-def] # pragma: no cover
|
||||
|
||||
|
||||
# Finally, register all previously-defined types, and patch in our new function
|
||||
for typ in pydantic.types._DEFINED_TYPES:
|
||||
for typ in list(pydantic.types._DEFINED_TYPES):
|
||||
_registered(typ)
|
||||
pydantic.types._registered = _registered
|
||||
st.register_type_strategy(pydantic.Json, resolve_json)
|
||||
|
||||
Reference in New Issue
Block a user