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