MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _test_list_dataclasses

Method _test_list_dataclasses

test/orm/test_collection.py:550–577  ·  view source on GitHub ↗
(self, typecallable)

Source from the content-addressed store, hash-verified

548 self.assert_(e7 not in canary.removed)
549
550 def _test_list_dataclasses(self, typecallable):
551 creator = self.SimpleComparableEntity
552
553 @dataclasses.dataclass
554 class Foo:
555 attr: List[Any] = dataclasses.field(default_factory=list)
556
557 canary = Canary()
558 instrumentation.register_class(Foo)
559 d = _register_attribute(
560 Foo,
561 "attr",
562 uselist=True,
563 typecallable=typecallable,
564 useobject=True,
565 )
566 canary.listen(d)
567
568 obj = Foo()
569 direct = obj.attr
570
571 e1 = creator(a=1, b=2)
572 collections.collection_adapter(direct).append_with_event(e1)
573
574 like_me = typecallable()
575 like_me.append(e1)
576
577 eq_(dataclasses.asdict(obj), {"attr": like_me})
578
579 def test_list(self):
580 self._test_adapter(list)

Callers 2

test_listMethod · 0.95
test_list_subclassMethod · 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
appendMethod · 0.45

Tested by

no test coverage detected