MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_lazy_list

Method test_lazy_list

test/ext/test_associationproxy.py:1356–1380  ·  test/ext/test_associationproxy.py::LazyLoadTest.test_lazy_list
(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(class="st">"Parent", class="st">"Child")
1358
1359 self.session = fixture_session()
1360
1361 self.mapper_registry.map_imperatively(
1362 Parent,
1363 self.tables.Parent,
1364 properties={
1365 class="st">"_children": relationship(
1366 Child, lazy=class="st">"select", collection_class=list
1367 )
1368 },
1369 )
1370
1371 p = Parent(class="st">"p")
1372 p.children = [class="st">"a", class="st">"b", class="st">"c"]
1373
1374 p = self.roundtrip(p)
1375
1376 class="cm"># Is there a better way to ensure that the association_proxy
1377 class="cm"># didn't convert a lazy load to an eager load? This does work though.
1378 self.assert_(class="st">"_children" not in p.__dict__)
1379 self.assert_(len(p._children) == 3)
1380 self.assert_(class="st">"_children" in p.__dict__)
1381
1382 def test_eager_list(self):
1383 Parent, Child = self.classes(class="st">"Parent", class="st">"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