MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _test_set_dataclasses

Method _test_set_dataclasses

test/orm/test_collection.py:1082–1109  ·  test/orm/test_collection.py::CollectionsTest._test_set_dataclasses
(self, typecallable)

Source from the content-addressed store, hash-verified

1080 self.assert_(e3 in canary.data)
1081
1082 def _test_set_dataclasses(self, typecallable):
1083 creator = self.SimpleComparableEntity
1084
1085 @dataclasses.dataclass
1086 class Foo:
1087 attr: MutableSet[Any] = dataclasses.field(default_factory=set)
1088
1089 canary = Canary()
1090 instrumentation.register_class(Foo)
1091 d = _register_attribute(
1092 Foo,
1093 class="st">"attr",
1094 uselist=True,
1095 typecallable=typecallable,
1096 useobject=True,
1097 )
1098 canary.listen(d)
1099
1100 obj = Foo()
1101 direct = obj.attr
1102
1103 e1 = creator(a=1, b=2)
1104 collections.collection_adapter(direct).append_with_event(e1)
1105
1106 like_me = typecallable()
1107 like_me.add(e1)
1108
1109 eq_(dataclasses.asdict(obj), {class="st">"attr": like_me})
1110
1111 def test_set(self):
1112 self._test_adapter(set)

Callers 4

test_setMethod · 0.95
test_set_subclassMethod · 0.95
test_set_duckMethod · 0.95
test_set_emulatesMethod · 0.95

Calls 8

listenMethod · 0.95
eq_Function · 0.90
CanaryClass · 0.85
creatorFunction · 0.85
append_with_eventMethod · 0.80
_register_attributeFunction · 0.70
FooClass · 0.70
addMethod · 0.45

Tested by

no test coverage detected