File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/testing/src/execution_testing/base_types Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -31,8 +31,20 @@ class CopyValidateModel(EthereumTestBaseModel):
3131 def copy (self : Self , ** kwargs : Any ) -> Self :
3232 """
3333 Create a copy of the model with the updated fields that are validated.
34+
35+ This method preserves the actual field values (including those set via
36+ default_factory) while maintaining the model_fields_set to track which
37+ fields were explicitly set.
3438 """
35- return self .__class__ (** (self .model_dump (exclude_unset = True ) | kwargs ))
39+ # Get all current field values, including those set via default_factory
40+ dump_dict = self .model_dump ()
41+ # Merge with the updates
42+ dump_dict .update (kwargs )
43+ # Create the new instance
44+ new_instance = self .__class__ (** dump_dict )
45+ # Preserve the original model_fields_set, adding any new kwargs
46+ new_instance .__pydantic_fields_set__ = self .model_fields_set | kwargs .keys ()
47+ return new_instance
3648
3749
3850class CamelModel (CopyValidateModel ):
You can’t perform that action at this time.
0 commit comments