MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_registry_setdefault

Method test_registry_setdefault

test/orm/test_utils.py:992–1011  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

990 assert not p2.contains(reg, "fake")
991
992 def test_registry_setdefault(self):
993 reg = {}
994 umapper = inspect(self.classes.User)
995 amapper = inspect(self.classes.Address)
996
997 p1 = PathRegistry.coerce((umapper, umapper.attrs.addresses))
998 p2 = PathRegistry.coerce((umapper, umapper.attrs.addresses, amapper))
999 reg.update({("p1key", p1.path): "p1value"})
1000
1001 p1.setdefault(reg, "p1key", "p1newvalue_a")
1002 p1.setdefault(reg, "p1key_new", "p1newvalue_b")
1003 p2.setdefault(reg, "p2key", "p2newvalue")
1004 eq_(
1005 reg,
1006 {
1007 ("p1key", p1.path): "p1value",
1008 ("p1key_new", p1.path): "p1newvalue_b",
1009 ("p2key", p2.path): "p2newvalue",
1010 },
1011 )
1012
1013 def test_serialize(self):
1014 User = self.classes.User

Callers

nothing calls this directly

Calls 5

inspectFunction · 0.90
eq_Function · 0.90
coerceMethod · 0.45
updateMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected