Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/14434.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :option:`--pastebin` option is now deprecated.
The same functionality is now available in an external plugin, :pypi:`pytest-pastebin`.
See :ref:`pastebin-deprecated` for more details.
13 changes: 13 additions & 0 deletions doc/en/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ Below is a complete list of all pytest features which are considered deprecated.
:class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.


.. _pastebin-deprecated:

The ``--pastebin`` option
~~~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 9.1

The :option:`--pastebin` has been deprecated due to being very niche, relying on an external service and having low usage.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The :option:`--pastebin` has been deprecated due to being very niche, relying on an external service and having low usage.
The :option:`--pastebin` has been deprecated due to being very niche, being the only feature in pytest relying on an external service and having low usage.


The plugin which implements ``--pastebin`` has been extracted to a separate package, :pypi:`pytest-pastebin`.
Please install ``pytest-pastebin`` if you want to keep using ``--pastebin``.


.. _dynamic-fixture-request-during-teardown:

``request.getfixturevalue()`` during fixture teardown
Expand Down
6 changes: 6 additions & 0 deletions src/_pytest/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
"See https://docs.pytest.org/en/stable/deprecations.html#dynamic-fixture-request-during-teardown",
)

PASTEBIN = PytestRemovedIn10Warning(
"The --pastebin option is deprecated. "
"The functionality is now available in an external plugin package, pytest-pastebin.\n"
"See https://docs.pytest.org/en/stable/deprecations.html#pastebin"
)

# You want to make some `__init__` or function "private".
#
# def my_private_function(some, args):
Expand Down
4 changes: 4 additions & 0 deletions src/_pytest/pastebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from _pytest.config import Config
from _pytest.config import create_terminal_writer
from _pytest.config.argparsing import Parser
from _pytest.deprecated import PASTEBIN
from _pytest.stash import StashKey
from _pytest.terminal import TerminalReporter
import pytest
Expand All @@ -33,6 +34,9 @@ def pytest_addoption(parser: Parser) -> None:

@pytest.hookimpl(trylast=True)
def pytest_configure(config: Config) -> None:
if config.option.pastebin:
config.issue_config_time_warning(PASTEBIN, 2)

if config.option.pastebin == "all":
tr = config.pluginmanager.getplugin("terminalreporter")
# If no terminal reporter plugin is present, nothing we can do here;
Expand Down
21 changes: 19 additions & 2 deletions testing/test_pastebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io
from unittest import mock

from _pytest.config import ExitCode
from _pytest.monkeypatch import MonkeyPatch
from _pytest.pytester import Pytester
import pytest
Expand Down Expand Up @@ -50,7 +51,13 @@ def test_skip():
pytest.skip("")
"""
)
reprec = pytester.inline_run(testpath, "--pastebin=all", "-v")
reprec = pytester.inline_run(
testpath,
"--pastebin=all",
"-v",
"-W",
"ignore:The --pastebin:DeprecationWarning",
)
assert reprec.countoutcomes() == [1, 1, 1]
assert len(pastebinlist) == 1
contents = pastebinlist[0].decode("utf-8")
Expand All @@ -74,7 +81,11 @@ def test():
assert '☺' == 1
"""
)
result = pytester.runpytest("--pastebin=all")
result = pytester.runpytest(
"--pastebin=all",
"-W",
"ignore:The --pastebin:DeprecationWarning",
)
expected_msg = "*assert '☺' == 1*"
result.stdout.fnmatch_lines(
[
Expand All @@ -85,6 +96,12 @@ def test():
)
assert len(pastebinlist) == 1

def test_deprecated(self, pytester: Pytester, pastebinlist) -> None:
result = pytester.runpytest("--pastebin=failed")
assert result.ret == ExitCode.NO_TESTS_COLLECTED
result.assert_outcomes()
result.stdout.fnmatch_lines(["*The --pastebin option is deprecated*"])


class TestPaste:
@pytest.fixture
Expand Down
Loading