Skip to content

Commit 9b6f8d4

Browse files
authored
add tests for skipping property methods on plugin registration
1 parent 76d72cd commit 9b6f8d4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

testing/test_pluginmanager.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ class A:
123123
assert pm.register(A(), "somename")
124124

125125

126+
def test_register_skips_properties(he_pm: PluginManager) -> None:
127+
property_was_executed = False
128+
class A:
129+
@property
130+
def some_func(self):
131+
property_was_executed = True
132+
133+
a = A()
134+
he_pm.register(a)
135+
assert not property_was_executed
136+
137+
138+
def test_register_skips_pydantic_fields(he_pm: PluginManager) -> None:
139+
class A:
140+
# stub to make object look like a pydantic model
141+
model_fields = {'some_attr': {}}
142+
143+
def __pydantic_core_schema__(self): ...
144+
145+
@hookimpl
146+
def some_attr(self): ...
147+
148+
a = A()
149+
pname = he_pm.register(a)
150+
assert not pm.get_hookcallers(pm.get_plugin(pname))
151+
152+
126153
def test_register_mismatch_method(he_pm: PluginManager) -> None:
127154
class hello:
128155
@hookimpl

0 commit comments

Comments
 (0)