Remove 'pytest.config'
This commit is contained in:
parent
f2b7809d5d
commit
7e58defc15
|
@ -11,6 +11,8 @@ removed:
|
|||
syntax. This might change the exception message from previous versions, but they still raise
|
||||
``TypeError`` on unknown keyword arguments as before.
|
||||
|
||||
* ``pytest.config`` global variable.
|
||||
|
||||
|
||||
For more information consult
|
||||
`Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs.
|
||||
|
|
|
@ -34,19 +34,6 @@ in places where we or plugin authors must distinguish between fixture names and
|
|||
names supplied by non-fixture things such as ``pytest.mark.parametrize``.
|
||||
|
||||
|
||||
|
||||
|
||||
``pytest.config`` global
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 4.1
|
||||
|
||||
The ``pytest.config`` global object is deprecated. Instead use
|
||||
``request.config`` (via the ``request`` fixture) or if you are a plugin author
|
||||
use the ``pytest_configure(config)`` hook. Note that many hooks can also access
|
||||
the ``config`` object indirectly, through ``session.config`` or ``item.config`` for example.
|
||||
|
||||
|
||||
Result log (``--result-log``)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -63,6 +50,7 @@ stable.
|
|||
|
||||
The actual alternative is still being discussed in issue `#4488 <https://github.com/pytest-dev/pytest/issues/4488>`__.
|
||||
|
||||
|
||||
Removed Features
|
||||
----------------
|
||||
|
||||
|
@ -70,6 +58,17 @@ As stated in our :ref:`backwards-compatibility` policy, deprecated features are
|
|||
an appropriate period of deprecation has passed.
|
||||
|
||||
|
||||
``pytest.config`` global
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. versionremoved:: 5.0
|
||||
|
||||
The ``pytest.config`` global object is deprecated. Instead use
|
||||
``request.config`` (via the ``request`` fixture) or if you are a plugin author
|
||||
use the ``pytest_configure(config)`` hook. Note that many hooks can also access
|
||||
the ``config`` object indirectly, through ``session.config`` or ``item.config`` for example.
|
||||
|
||||
|
||||
.. _`raises message deprecated`:
|
||||
|
||||
``"message"`` parameter of ``pytest.raises``
|
||||
|
|
|
@ -46,11 +46,6 @@ RESULT_LOG = PytestDeprecationWarning(
|
|||
)
|
||||
|
||||
|
||||
PYTEST_CONFIG_GLOBAL = PytestDeprecationWarning(
|
||||
"the `pytest.config` global is deprecated. Please use `request.config` "
|
||||
"or `pytest_configure` (if you're a pytest plugin) instead."
|
||||
)
|
||||
|
||||
PYTEST_ENSURETEMP = RemovedInPytest4Warning(
|
||||
"pytest/tmpdir_factory.ensuretemp is deprecated, \n"
|
||||
"please use the tmp_path fixture or tmp_path_factory.mktemp"
|
||||
|
|
|
@ -5,7 +5,6 @@ import functools
|
|||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import attr
|
||||
import py
|
||||
|
@ -15,7 +14,6 @@ from _pytest import nodes
|
|||
from _pytest.config import directory_arg
|
||||
from _pytest.config import hookimpl
|
||||
from _pytest.config import UsageError
|
||||
from _pytest.deprecated import PYTEST_CONFIG_GLOBAL
|
||||
from _pytest.outcomes import exit
|
||||
from _pytest.runner import collect_one_node
|
||||
|
||||
|
@ -179,26 +177,6 @@ def pytest_addoption(parser):
|
|||
)
|
||||
|
||||
|
||||
class _ConfigDeprecated:
|
||||
def __init__(self, config):
|
||||
self.__dict__["_config"] = config
|
||||
|
||||
def __getattr__(self, attr):
|
||||
warnings.warn(PYTEST_CONFIG_GLOBAL, stacklevel=2)
|
||||
return getattr(self._config, attr)
|
||||
|
||||
def __setattr__(self, attr, val):
|
||||
warnings.warn(PYTEST_CONFIG_GLOBAL, stacklevel=2)
|
||||
return setattr(self._config, attr, val)
|
||||
|
||||
def __repr__(self):
|
||||
return "{}({!r})".format(type(self).__name__, self._config)
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
__import__("pytest").config = _ConfigDeprecated(config) # compatibility
|
||||
|
||||
|
||||
def wrap_session(config, doit):
|
||||
"""Skeleton command line program"""
|
||||
session = Session(config)
|
||||
|
|
|
@ -72,8 +72,7 @@ def test_make_hook_recorder(testdir):
|
|||
def test_parseconfig(testdir):
|
||||
config1 = testdir.parseconfig()
|
||||
config2 = testdir.parseconfig()
|
||||
assert config2 != config1
|
||||
assert config1 != pytest.config
|
||||
assert config2 is not config1
|
||||
|
||||
|
||||
def test_testdir_runs_with_plugin(testdir):
|
||||
|
|
Loading…
Reference in New Issue