test that a 'set' can be used as a collection and can lazyload.
(self)
| 2384 | assert isinstance(f.bars, MyList) |
| 2385 | |
| 2386 | def test_lazyload(self): |
| 2387 | """test that a 'set' can be used as a collection and can lazyload.""" |
| 2388 | |
| 2389 | someothertable, sometable = ( |
| 2390 | self.tables.someothertable, |
| 2391 | self.tables.sometable, |
| 2392 | ) |
| 2393 | |
| 2394 | class Foo: |
| 2395 | pass |
| 2396 | |
| 2397 | class Bar: |
| 2398 | pass |
| 2399 | |
| 2400 | self.mapper_registry.map_imperatively( |
| 2401 | Foo, |
| 2402 | sometable, |
| 2403 | properties={"bars": relationship(Bar, collection_class=set)}, |
| 2404 | ) |
| 2405 | self.mapper_registry.map_imperatively(Bar, someothertable) |
| 2406 | f = Foo() |
| 2407 | f.bars.add(Bar()) |
| 2408 | f.bars.add(Bar()) |
| 2409 | sess = fixture_session() |
| 2410 | sess.add(f) |
| 2411 | sess.flush() |
| 2412 | sess.expunge_all() |
| 2413 | f = sess.get(Foo, f.col1) |
| 2414 | assert len(list(f.bars)) == 2 |
| 2415 | f.bars.clear() |
| 2416 | |
| 2417 | def test_dict(self): |
| 2418 | """test that a 'dict' can be used as a collection and can lazyload.""" |
nothing calls this directly
no test coverage detected