Skip to content

Commit

Permalink
Prove that PluginManger.register() ignores non-routines
Browse files Browse the repository at this point in the history
This proves that pytest-dev#91 is a problem in `pytest` and not `pluggy`.
Thanks to @RonnyPfannschmidt for the fix about a year ago ;)
  • Loading branch information
Tyler Goodlet committed Nov 12, 2017
1 parent 4fb708b commit 5f52422
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import types

from pluggy import (PluginValidationError,
HookCallError, HookimplMarker, HookspecMarker)
Expand Down Expand Up @@ -350,3 +351,17 @@ 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 = types.ModuleType("conftest")
conftest.example_blah = types.ModuleType("example_blah")
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

0 comments on commit 5f52422

Please sign in to comment.