fix issue #1073 -- shortcut plugin hook lookup if the attrname is not
prefixed with pytest_.
This commit is contained in:
parent
d29084ec2c
commit
4e3a807733
|
@ -174,6 +174,12 @@ class PytestPluginManager(PluginManager):
|
||||||
if exclude_pytest_names(name):
|
if exclude_pytest_names(name):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# pytest hooks are always prefixed with pytest_
|
||||||
|
# so we avoid accessing possibly non-readable attributes
|
||||||
|
# (see issue #1073)
|
||||||
|
if not name.startswith("pytest_"):
|
||||||
|
return
|
||||||
|
|
||||||
method = getattr(plugin, name)
|
method = getattr(plugin, name)
|
||||||
opts = super(PytestPluginManager, self).parse_hookimpl_opts(plugin, name)
|
opts = super(PytestPluginManager, self).parse_hookimpl_opts(plugin, name)
|
||||||
if opts is not None:
|
if opts is not None:
|
||||||
|
|
|
@ -388,3 +388,19 @@ def test_search_conftest_up_to_inifile(testdir, confcutdir, passed, error):
|
||||||
if error:
|
if error:
|
||||||
match += '*%d error*' % error
|
match += '*%d error*' % error
|
||||||
result.stdout.fnmatch_lines(match)
|
result.stdout.fnmatch_lines(match)
|
||||||
|
|
||||||
|
|
||||||
|
def test_issue1073_conftest_special_objects(testdir):
|
||||||
|
testdir.makeconftest("""
|
||||||
|
class DontTouchMe:
|
||||||
|
def __getattr__(self, x):
|
||||||
|
raise Exception('cant touch me')
|
||||||
|
|
||||||
|
x = DontTouchMe()
|
||||||
|
""")
|
||||||
|
testdir.makepyfile("""
|
||||||
|
def test_some():
|
||||||
|
pass
|
||||||
|
""")
|
||||||
|
res = testdir.runpytest()
|
||||||
|
assert res.ret == 0
|
||||||
|
|
Loading…
Reference in New Issue