MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_unregister

Method test_unregister

test/ext/test_extendedattr.py:103–147  ·  test/ext/test_extendedattr.py::DisposeTest.test_unregister
(self, registry)

Source from the content-addressed store, hash-verified

101
102class DisposeTest(_ExtBase, fixtures.TestBase):
103 def test_unregister(self, registry):
104 class MyClassState(instrumentation.InstrumentationManager):
105 def manage(self, class_, manager):
106 setattr(class_, class="st">"xyz", manager)
107
108 def unregister(self, class_, manager):
109 delattr(class_, class="st">"xyz")
110
111 def manager_getter(self, class_):
112 def get(cls):
113 return cls.xyz
114
115 return get
116
117 class MyClass:
118 __sa_instrumentation_manager__ = MyClassState
119
120 assert attributes.opt_manager_of_class(MyClass) is None
121
122 with expect_raises_message(
123 sa.orm.exc.UnmappedClassError,
124 rclass="st">"Can&class="cm">#x27;t locate an instrumentation manager for class .*MyClass",
125 ):
126 attributes.manager_of_class(MyClass)
127
128 t = Table(
129 class="st">"my_table",
130 registry.metadata,
131 Column(class="st">"id", Integer, primary_key=True),
132 )
133
134 registry.map_imperatively(MyClass, t)
135
136 manager = attributes.opt_manager_of_class(MyClass)
137 is_not(manager, None)
138 is_(manager, MyClass.xyz)
139
140 registry.configure()
141
142 registry.dispose()
143
144 manager = attributes.opt_manager_of_class(MyClass)
145 is_(manager, None)
146
147 assert not hasattr(MyClass, class="st">"xyz")
148
149
150class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest):

Callers

nothing calls this directly

Calls 10

expect_raises_messageFunction · 0.90
TableClass · 0.90
ColumnClass · 0.90
is_notFunction · 0.90
is_Function · 0.90
opt_manager_of_classMethod · 0.80
manager_of_classMethod · 0.80
map_imperativelyMethod · 0.80
configureMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected