MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_name_setup

Method test_name_setup

test/orm/test_collection.py:2791–2823  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2789
2790class InstrumentationTest(fixtures.ORMTest):
2791 def test_name_setup(self):
2792
2793 class Base:
2794 @collection.iterator
2795 def base_iterate(self, x):
2796 return "base_iterate"
2797
2798 @collection.appender
2799 def base_append(self, x):
2800 return "base_append"
2801
2802 @collection.remover
2803 def base_remove(self, x):
2804 return "base_remove"
2805
2806 from sqlalchemy.orm.collections import _instrument_class
2807
2808 _instrument_class(Base)
2809
2810 eq_(Base._sa_remover(Base(), 5), "base_remove")
2811 eq_(Base._sa_appender(Base(), 5), "base_append")
2812 eq_(Base._sa_iterator(Base(), 5), "base_iterate")
2813
2814 class Sub(Base):
2815 @collection.remover
2816 def sub_remove(self, x):
2817 return "sub_remove"
2818
2819 _instrument_class(Sub)
2820
2821 eq_(Sub._sa_appender(Sub(), 5), "base_append")
2822 eq_(Sub._sa_remover(Sub(), 5), "sub_remove")
2823 eq_(Sub._sa_iterator(Sub(), 5), "base_iterate")
2824
2825 def test_uncooperative_descriptor_in_sweep(self):
2826 class DoNotTouch:

Callers

nothing calls this directly

Calls 6

_instrument_classFunction · 0.90
eq_Function · 0.90
_sa_removerMethod · 0.80
_sa_appenderMethod · 0.80
BaseClass · 0.70
SubClass · 0.70

Tested by

no test coverage detected