diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index 7e9701b3..6ac02419 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -1,4 +1,5 @@ import pytest +import imp from pluggy import (PluginValidationError, HookCallError, HookimplMarker, HookspecMarker) @@ -350,3 +351,20 @@ def m(self, __multicall__, x): def test_add_hookspecs_nohooks(pm): with pytest.raises(ValueError): pm.add_hookspecs(10) + + +def test_reject_prefixed_module(pm): + """Verify that a module type attribute that contains the project + prefix in its name (in this case `'example_*'` isn't collected + when registering a module which imports it. + """ + pm._implprefix = 'example' + conftest = imp.new_module("conftest") + # note project prefix for ``pm`` is 'example' + conftest.example_blah = imp.new_module("example_blah") + + # import pdb; pdb.set_trace() + name = pm.register(conftest) + assert name == 'conftest' + assert getattr(pm.hook, 'example_blah', None) is None + assert pm.parse_hookimpl_opts(conftest, 'example_blah') is None