(self, registry)
| 101 | |
| 102 | class 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 | |
| 150 | class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest): |
nothing calls this directly
no test coverage detected