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

Method test_lazy_list

test/ext/test_associationproxy.py:1356–1380  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1354 return self.session.get(type_, id_)
1355
1356 def test_lazy_list(self):
1357 Parent, Child = self.classes("Parent", "Child")
1358
1359 self.session = fixture_session()
1360
1361 self.mapper_registry.map_imperatively(
1362 Parent,
1363 self.tables.Parent,
1364 properties={
1365 "_children": relationship(
1366 Child, lazy="select", collection_class=list
1367 )
1368 },
1369 )
1370
1371 p = Parent("p")
1372 p.children = ["a", "b", "c"]
1373
1374 p = self.roundtrip(p)
1375
1376 # Is there a better way to ensure that the association_proxy
1377 # didn't convert a lazy load to an eager load? This does work though.
1378 self.assert_("_children" not in p.__dict__)
1379 self.assert_(len(p._children) == 3)
1380 self.assert_("_children" in p.__dict__)
1381
1382 def test_eager_list(self):
1383 Parent, Child = self.classes("Parent", "Child")

Callers

nothing calls this directly

Calls 6

roundtripMethod · 0.95
fixture_sessionFunction · 0.90
relationshipFunction · 0.90
map_imperativelyMethod · 0.80
ParentClass · 0.70
assert_Method · 0.45

Tested by

no test coverage detected