Merge pull request #1080 from vodik/master
fix #1034: Add missing nodeid on pytest_logwarning call in addhook. Thanks Simon Gomizelj for the PR.
This commit is contained in:
commit
a73d517bee
|
@ -159,6 +159,7 @@ class PytestPluginManager(PluginManager):
|
|||
"""
|
||||
warning = dict(code="I2",
|
||||
fslocation=py.code.getfslineno(sys._getframe(1)),
|
||||
nodeid=None,
|
||||
message="use pluginmanager.add_hookspecs instead of "
|
||||
"deprecated addhooks() method.")
|
||||
self._warn(warning)
|
||||
|
|
|
@ -145,6 +145,23 @@ class TestPytestPluginInteractions:
|
|||
assert len(warnings) == len(before) + 1
|
||||
assert "deprecated" in warnings[-1]
|
||||
|
||||
def test_warn_on_deprecated_addhooks(self, pytestpm):
|
||||
warnings = []
|
||||
|
||||
class get_warnings:
|
||||
def pytest_logwarning(self, code, fslocation, message, nodeid):
|
||||
warnings.append(message)
|
||||
|
||||
class Plugin:
|
||||
def pytest_testhook():
|
||||
pass
|
||||
|
||||
pytestpm.register(get_warnings())
|
||||
before = list(warnings)
|
||||
pytestpm.addhooks(Plugin())
|
||||
assert len(warnings) == len(before) + 1
|
||||
assert "deprecated" in warnings[-1]
|
||||
|
||||
|
||||
def test_namespace_has_default_and_env_plugins(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
|
|
Loading…
Reference in New Issue