Merge remote-tracking branch 'graingert/warn-when-a-mark-is-applied-to-a-fixture' into warn-when-a-mark-is-applied-to-a-fixture
This commit is contained in:
commit
2998b596b4
|
@ -1 +1,3 @@
|
|||
Applying a mark to a fixture function is deprecated. Doing so has no effect.
|
||||
Applying a mark to a fixture function now issues a warning: marks in fixtures never had any effect, but it is a common user error to apply a mark to a fixture (for example ``usefixtures``) and expect it to work.
|
||||
|
||||
This will become an error in the future.
|
||||
|
|
|
@ -278,7 +278,17 @@ Applying a mark to a fixture function
|
|||
|
||||
.. deprecated:: 7.2
|
||||
|
||||
Applying a mark to a fixture function is deprecated. Doing so has no effect, and will raise an error in the next version.
|
||||
Applying a mark to a fixture function never had any effect, but it is a common user error.
|
||||
|
||||
.. code-block:: python
|
||||
@pytest.mark.usefixtures("clean_database")
|
||||
@pytest.fixture
|
||||
def user() -> User:
|
||||
...
|
||||
|
||||
Users expected in this case that the ``usefixtures`` mark would have its intended effect of using the ``clean_database`` fixture when ``user`` was invoked, when in fact it has no effect at all.
|
||||
|
||||
Now pytest will issue a warning when it encounters this problem, and will raise an error in the future versions.
|
||||
|
||||
|
||||
Backward compatibilities in ``Parser.addoption``
|
||||
|
|
|
@ -107,7 +107,10 @@ HOOK_LEGACY_MARKING = UnformattedWarning(
|
|||
"#configuring-hook-specs-impls-using-markers",
|
||||
)
|
||||
|
||||
MARKED_FIXTURE = PytestDeprecationWarning("Marks applied to fixtures have no effect")
|
||||
MARKED_FIXTURE = PytestDeprecationWarning(
|
||||
"Marks applied to fixtures have no effect\n"
|
||||
"See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function"
|
||||
)
|
||||
|
||||
# You want to make some `__init__` or function "private".
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue