MCPcopy
hub / github.com/pydantic/pydantic / test_root_model_shallow_copy

Function test_root_model_shallow_copy

tests/test_root_model.py:630–644  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

628
629
630def test_root_model_shallow_copy() -> None:
631 class ListRootModel(RootModel[list[int]]):
632 pass
633
634 original = ListRootModel([1, 2, 3])
635 copied = original.model_copy(deep=False)
636
637 assert original is not copied
638 # Root value is also shallow copied, see https://github.com/pydantic/pydantic/issues/12543:
639 assert original.root is not copied.root
640 assert original.root == copied.root
641
642 copied.root.append(4)
643 assert original.root == [1, 2, 3]
644 assert copied.root == [1, 2, 3, 4]
645
646
647def test_root_model_deep_copy() -> None:

Callers

nothing calls this directly

Calls 2

ListRootModelClass · 0.85
model_copyMethod · 0.80

Tested by

no test coverage detected