MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_object_collections_set

Method test_object_collections_set

test/orm/test_attributes.py:2483–2570  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2481 eq_(self._someattr_history(f), ([there], (), ()))
2482
2483 def test_object_collections_set(self):
2484 # TODO: break into individual tests
2485
2486 Foo, Bar = self._two_obj_fixture(uselist=True)
2487 hi = Bar(name="hi")
2488 there = Bar(name="there")
2489 old = Bar(name="old")
2490 new = Bar(name="new")
2491
2492 # case 1. new object
2493
2494 f = Foo()
2495 eq_(
2496 attributes.get_state_history(
2497 attributes.instance_state(f), "someattr"
2498 ),
2499 ((), [], ()),
2500 )
2501 f.someattr = [hi]
2502 eq_(
2503 attributes.get_state_history(
2504 attributes.instance_state(f), "someattr"
2505 ),
2506 ([hi], [], []),
2507 )
2508 self._commit_someattr(f)
2509 eq_(
2510 attributes.get_state_history(
2511 attributes.instance_state(f), "someattr"
2512 ),
2513 ((), [hi], ()),
2514 )
2515 f.someattr = [there]
2516 eq_(
2517 attributes.get_state_history(
2518 attributes.instance_state(f), "someattr"
2519 ),
2520 ([there], [], [hi]),
2521 )
2522 self._commit_someattr(f)
2523 eq_(
2524 attributes.get_state_history(
2525 attributes.instance_state(f), "someattr"
2526 ),
2527 ((), [there], ()),
2528 )
2529 f.someattr = [hi]
2530 eq_(
2531 attributes.get_state_history(
2532 attributes.instance_state(f), "someattr"
2533 ),
2534 ([hi], [], [there]),
2535 )
2536 f.someattr = [old, new]
2537 eq_(
2538 attributes.get_state_history(
2539 attributes.instance_state(f), "someattr"
2540 ),

Callers

nothing calls this directly

Calls 8

_two_obj_fixtureMethod · 0.95
_commit_someattrMethod · 0.95
eq_Function · 0.90
init_collectionMethod · 0.80
append_without_eventMethod · 0.80
_commit_allMethod · 0.80
BarClass · 0.70
FooClass · 0.70

Tested by

no test coverage detected