From a93f41233a8f4edadb33a055396247ef1ede210a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 19 Dec 2018 18:09:47 -0200 Subject: [PATCH] Raise an error if pytest_plugins is defined in a non-top-level conftest.py file Fix #4548 --- changelog/4548.removal.rst | 3 +++ doc/en/deprecations.rst | 20 ++++++++++---------- src/_pytest/config/__init__.py | 11 ++++++----- src/_pytest/deprecated.py | 10 +++++++--- testing/deprecated_test.py | 22 ++++++++-------------- 5 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 changelog/4548.removal.rst diff --git a/changelog/4548.removal.rst b/changelog/4548.removal.rst new file mode 100644 index 000000000..bd47b1d51 --- /dev/null +++ b/changelog/4548.removal.rst @@ -0,0 +1,3 @@ +An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``). + +See our `docs `__ for more information. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 781d05b77..ca95bab38 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -81,16 +81,6 @@ As part of a large :ref:`marker-revamp`, :meth:`_pytest.nodes.Node.get_marker` i :ref:`the documentation ` on tips on how to update your code. -pytest_plugins in non-top-level conftest files -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 3.5 - -Defining ``pytest_plugins`` is now deprecated in non-top-level conftest.py -files because they will activate referenced plugins *globally*, which is surprising because for all other pytest -features ``conftest.py`` files are only *active* for tests at or below it. - - marks in ``pytest.mark.parametrize`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -242,6 +232,16 @@ You can consult `funcarg comparison section in the docs