MCPcopy
hub / github.com/pydantic/pydantic / test_deep_copy

Function test_deep_copy

tests/test_construction.py:164–175  ·  view source on GitHub ↗
(ModelTwo, copy_method)

Source from the content-addressed store, hash-verified

162
163
164def test_deep_copy(ModelTwo, copy_method):
165 m = ModelTwo(a=24, d=Model(a='12'))
166 m._foo_ = {'new value'}
167 m2 = copy_method(m, deep=True)
168
169 assert m.a == m2.a == 24
170 assert m.b == m2.b == 10
171 assert m.c == m2.c == 'foobar'
172 assert m.d is not m2.d
173 assert m == m2
174 assert m._foo_ == m2._foo_
175 assert m._foo_ is not m2._foo_
176
177
178@pytest.mark.thread_unsafe(reason='`pytest.warns()` is thread unsafe')

Callers

nothing calls this directly

Calls 3

copy_methodFunction · 0.85
ModelTwoClass · 0.70
ModelClass · 0.70

Tested by

no test coverage detected