MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _test_set_wo_mutation

Method _test_set_wo_mutation

test/orm/test_collection.py:720–760  ·  view source on GitHub ↗
(self, typecallable, creator=None)

Source from the content-addressed store, hash-verified

718 self.assert_(getattr(ListIsh, "_sa_instrumented") == id(ListIsh))
719
720 def _test_set_wo_mutation(self, typecallable, creator=None):
721 if creator is None:
722 creator = self.entity_maker
723
724 class Foo:
725 pass
726
727 canary = Canary()
728 instrumentation.register_class(Foo)
729 d = _register_attribute(
730 Foo,
731 "attr",
732 uselist=True,
733 typecallable=typecallable,
734 useobject=True,
735 )
736 canary.listen(d)
737
738 obj = Foo()
739
740 e = creator()
741
742 obj.attr.add(e)
743
744 assert e in canary.added
745 assert e not in canary.appended_wo_mutation
746
747 obj.attr.add(e)
748 assert e in canary.added
749 assert e in canary.appended_wo_mutation
750
751 e = creator()
752
753 obj.attr.update({e})
754
755 assert e in canary.added
756 assert e not in canary.appended_wo_mutation
757
758 obj.attr.update({e})
759 assert e in canary.added
760 assert e in canary.appended_wo_mutation
761
762 def _test_set(self, typecallable, creator=None):
763 if creator is None:

Callers 1

test_setMethod · 0.95

Calls 7

listenMethod · 0.95
CanaryClass · 0.85
creatorFunction · 0.85
_register_attributeFunction · 0.70
FooClass · 0.70
addMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected