Skip to content

Commit

Permalink
Warn when implementations exist for pytest_namespace hook
Browse files Browse the repository at this point in the history
This hook has been deprecated and will be removed in the future.

Fix #2639
  • Loading branch information
nicoddemus committed Jul 30, 2018
1 parent 0e47599 commit e3d412d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog/2639.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``pytest_namespace`` has been deprecated.

Plugins who need this feature are suggested to import ``pytest`` and set attributes explicitly during ``pytest_configure``.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main():
# if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy;
# used by tox.ini to test with pluggy master
if "_PYTEST_SETUP_SKIP_PLUGGY_DEP" not in os.environ:
install_requires.append("pluggy>=0.5,<0.8")
install_requires.append("pluggy>=0.7")
environment_marker_support_level = get_environment_marker_support_level()
if environment_marker_support_level >= 2:
install_requires.append('funcsigs;python_version<"3.0"')
Expand Down
15 changes: 13 additions & 2 deletions src/_pytest/hookspec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" hook specifications for pytest plugins, invoked from main.py and builtin plugins. """

from pluggy import HookspecMarker
from .deprecated import RemovedInPytest4Warning

hookspec = HookspecMarker("pytest")

Expand All @@ -22,17 +23,27 @@ def pytest_addhooks(pluginmanager):
"""


@hookspec(historic=True)
@hookspec(
historic=True,
warn_on_impl=RemovedInPytest4Warning(
"pytest_namespace is deprecated and will be removed soon"
),
)
def pytest_namespace():
"""
(**Deprecated**) this hook causes direct monkeypatching on pytest, its use is strongly discouraged
return dict of name->object to be made globally available in
the pytest namespace.
This hook is called at plugin registration time.
.. note::
This hook is incompatible with ``hookwrapper=True``.
.. 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``.
"""


Expand Down

0 comments on commit e3d412d

Please sign in to comment.