Skip to content

Commit df14939

Browse files
committed
fixup! Add HookImpl.__repr__
1 parent f05da83 commit df14939

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pluggy/hooks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def __init__(self, plugin, plugin_name, function, hook_impl_opts):
317317
self.__dict__.update(hook_impl_opts)
318318

319319
def __repr__(self):
320-
return "<HookImpl plugin_name=%r, plugin_file=%r>" % (
320+
return "<HookImpl plugin_name=%r, plugin=%r>" % (
321321
self.plugin_name,
322-
self.plugin.__file__,
322+
self.plugin,
323323
)

testing/test_details.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,20 @@ def myhook(self, arg1):
117117
warning = warns[-1]
118118
assert issubclass(warning.category, Warning)
119119
assert "Argument(s) ('arg2',)" in str(warning.message)
120+
121+
122+
def test_repr():
123+
class Plugin:
124+
@hookimpl
125+
def myhook():
126+
raise NotImplementedError()
127+
128+
pm = PluginManager(hookspec.project_name)
129+
130+
plugin = Plugin()
131+
pname = pm.register(plugin)
132+
assert repr(pm.hook.myhook._nonwrappers[0]) == (
133+
"<HookImpl plugin_name=%r, plugin=%r>" % (
134+
pname,
135+
plugin,
136+
))

0 commit comments

Comments
 (0)