From cf6d8e7e53f6fa4544e12d60b270c172a2e01ecf Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 30 Jul 2018 12:16:42 -0300 Subject: [PATCH] Fix test and update warning in pytest_namespace docs --- src/_pytest/hookspec.py | 11 +++++++++-- testing/test_pluginmanager.py | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 88b6ee455..cc577e8c3 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -42,8 +42,15 @@ def pytest_namespace(): .. warning:: This hook has been **deprecated** and will be removed in pytest 4.0. - Plugins who need this feature are suggested - to import ``pytest`` and set attributes explicitly during ``pytest_configure``. + Plugins whose users depend on the current namespace functionality should prepare to migrate to a + namespace they actually own. + + To support the migration its suggested to trigger ``DeprecationWarnings`` for objects they put into the + pytest namespace. + + An stopgap measure to avoid the warning is to monkeypatch the ``pytest`` module, but just as the + ``pytest_namespace`` hook this should be seen as a temporary measure to be removed in future versions after + an appropriate transition period. """ diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index c24314d22..958dfc650 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -66,6 +66,7 @@ class TestPytestPluginInteractions(object): result = testdir.runpython(p) assert result.ret == 0 + @pytest.mark.filterwarnings("ignore:pytest_namespace is deprecated") def test_do_ext_namespace(self, testdir): testdir.makeconftest( """