MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_bulk_replace

Method test_bulk_replace

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

Source from the content-addressed store, hash-verified

878 raise
879
880 def test_bulk_replace(self):
881 Parent = self.classes.Parent
882
883 p1 = Parent("foo")
884 p1.children = {"a", "b", "c"}
885 assocs = set(p1._children)
886 keep_assocs = {a for a in assocs if a.name in ("a", "c")}
887 eq_(len(keep_assocs), 2)
888 remove_assocs = {a for a in assocs if a.name == "b"}
889
890 p1.children = {"a", "c", "d"}
891 eq_({a for a in p1._children if a.name in ("a", "c")}, keep_assocs)
892 assert not remove_assocs.intersection(p1._children)
893
894 eq_(p1.children, {"a", "c", "d"})
895
896
897class CustomSetTest(SetTest):

Callers

nothing calls this directly

Calls 3

eq_Function · 0.90
ParentClass · 0.70
intersectionMethod · 0.45

Tested by

no test coverage detected