MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_bulk_replace

Method test_bulk_replace

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

Source from the content-addressed store, hash-verified

937 raise
938
939 def test_bulk_replace(self):
940 Parent = self.classes.Parent
941
942 p1 = Parent("foo")
943 p1.children = {"a", "b", "c"}
944 assocs = set(p1._children)
945 keep_assocs = {a for a in assocs if a.name in ("a", "c")}
946 eq_(len(keep_assocs), 2)
947 remove_assocs = {a for a in assocs if a.name == "b"}
948
949 p1.children = {"a", "c", "d"}
950 eq_({a for a in p1._children if a.name in ("a", "c")}, keep_assocs)
951 assert not remove_assocs.intersection(p1._children)
952
953 eq_(p1.children, {"a", "c", "d"})
954
955
956class 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