MCPcopy Index your code
hub / github.com/sqlalchemy/sqlalchemy / test_registry_setdefault

Method test_registry_setdefault

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

Source from the content-addressed store, hash-verified

974 assert not p2.contains(reg, "fake")
975
976 def test_registry_setdefault(self):
977 reg = {}
978 umapper = inspect(self.classes.User)
979 amapper = inspect(self.classes.Address)
980
981 p1 = PathRegistry.coerce((umapper, umapper.attrs.addresses))
982 p2 = PathRegistry.coerce((umapper, umapper.attrs.addresses, amapper))
983 reg.update({("p1key", p1.path): "p1value"})
984
985 p1.setdefault(reg, "p1key", "p1newvalue_a")
986 p1.setdefault(reg, "p1key_new", "p1newvalue_b")
987 p2.setdefault(reg, "p2key", "p2newvalue")
988 eq_(
989 reg,
990 {
991 ("p1key", p1.path): "p1value",
992 ("p1key_new", p1.path): "p1newvalue_b",
993 ("p2key", p2.path): "p2newvalue",
994 },
995 )
996
997 def test_serialize(self):
998 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