Skip to content

Commit 9d1d833

Browse files
authored
Fix pydantic @Property test
1 parent 8eecd23 commit 9d1d833

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

testing/test_pluginmanager.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,31 @@ class A:
124124

125125

126126
def test_register_skips_properties(he_pm: PluginManager) -> None:
127-
class A:
127+
class ClassWithProperties:
128128
@property
129129
def some_func(self):
130130
self.property_was_executed = True
131131
return None
132132

133-
a = A()
134-
he_pm.register(a)
135-
assert not a.property_was_executed
133+
test_plugin = ClassWithProperties()
134+
he_pm.register(test_plugin)
135+
assert not test_plugin.property_was_executed
136136

137137

138138
def test_register_skips_pydantic_fields(he_pm: PluginManager) -> None:
139-
class A:
139+
class PydanticModelClass:
140140
# stub to make object look like a pydantic model
141-
model_fields = {"some_attr": {}}
141+
model_fields: dict = {"some_attr": {}}
142142

143143
def __pydantic_core_schema__(self): ...
144144

145145
@hookimpl
146146
def some_attr(self): ...
147147

148-
a = A()
149-
pname = he_pm.register(a)
150-
assert not he_pm.get_hookcallers(he_pm.get_plugin(pname))
148+
test_plugin = PydanticModelClass()
149+
he_pm.register(test_plugin)
150+
with pytest.raises(AttributeError) as excinfo:
151+
he_pm.hook.some_attr.get_hookimpls()
151152

152153

153154
def test_register_mismatch_method(he_pm: PluginManager) -> None:

0 commit comments

Comments
 (0)