Skip to content

Commit 3fa0ab4

Browse files
author
Tyler Goodlet
committed
Prove that PluginManger.register() ignores non-routines
This proves that #91 is a problem in `pytest` and not `pluggy`. Thanks to @RonnyPfannschmidt for the fix about a year ago ;)
1 parent 4fb708b commit 3fa0ab4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

testing/test_pluginmanager.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import types
23

34
from pluggy import (PluginValidationError,
45
HookCallError, HookimplMarker, HookspecMarker)
@@ -350,3 +351,17 @@ def m(self, __multicall__, x):
350351
def test_add_hookspecs_nohooks(pm):
351352
with pytest.raises(ValueError):
352353
pm.add_hookspecs(10)
354+
355+
356+
def test_reject_prefixed_module(pm):
357+
"""Verify that a module type attribute that contains the project
358+
prefix in its name (in this case `'example_*'` isn't collected
359+
when registering a module which imports it.
360+
"""
361+
pm._implprefix = 'example'
362+
conftest = types.ModuleType("conftest")
363+
conftest.example_blah = types.ModuleType("example_blah")
364+
name = pm.register(conftest)
365+
assert name == 'conftest'
366+
assert getattr(pm.hook, 'example_blah', None) is None
367+
assert pm.parse_hookimpl_opts(conftest, 'example_blah') is None

0 commit comments

Comments
 (0)