Skip to content
Closed
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
1 change: 1 addition & 0 deletions changelog/5842.deprecation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``PytestPluginManager.getplugin()`` method has been removed. Use ``PytestPluginManager.get_plugin()`` instead.
12 changes: 6 additions & 6 deletions src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ def _is_started(self) -> bool:
@contextlib.contextmanager
def disabled(self) -> Generator[None]:
"""Temporarily disable capturing while inside the ``with`` block."""
capmanager: CaptureManager = self.request.config.pluginmanager.getplugin(
capmanager: CaptureManager = self.request.config.pluginmanager.get_plugin(
"capturemanager"
)
with capmanager.global_and_fixture_disabled():
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def test_output(capsys):
captured = capsys.readouterr()
assert captured.out == "hello\n"
"""
capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
capman: CaptureManager = request.config.pluginmanager.get_plugin("capturemanager")
capture_fixture = CaptureFixture(SysCapture, request, _ispytest=True)
capman.set_fixture(capture_fixture)
capture_fixture._start()
Expand Down Expand Up @@ -1061,7 +1061,7 @@ def test_output(capteesys):
captured = capteesys.readouterr()
assert captured.out == "hello\n"
"""
capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
capman: CaptureManager = request.config.pluginmanager.get_plugin("capturemanager")
capture_fixture = CaptureFixture(
SysCapture, request, config=dict(tee=True), _ispytest=True
)
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def test_output(capsysbinary):
captured = capsysbinary.readouterr()
assert captured.out == b"hello\n"
"""
capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
capman: CaptureManager = request.config.pluginmanager.get_plugin("capturemanager")
capture_fixture = CaptureFixture(SysCaptureBinary, request, _ispytest=True)
capman.set_fixture(capture_fixture)
capture_fixture._start()
Expand Down Expand Up @@ -1119,7 +1119,7 @@ def test_system_echo(capfd):
captured = capfd.readouterr()
assert captured.out == "hello\n"
"""
capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
capman: CaptureManager = request.config.pluginmanager.get_plugin("capturemanager")
capture_fixture = CaptureFixture(FDCapture, request, _ispytest=True)
capman.set_fixture(capture_fixture)
capture_fixture._start()
Expand Down Expand Up @@ -1148,7 +1148,7 @@ def test_system_echo(capfdbinary):
assert captured.out == b"hello\n"

"""
capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
capman: CaptureManager = request.config.pluginmanager.get_plugin("capturemanager")
capture_fixture = CaptureFixture(FDCaptureBinary, request, _ispytest=True)
capman.set_fixture(capture_fixture)
capture_fixture._start()
Expand Down
5 changes: 0 additions & 5 deletions src/_pytest/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,11 +615,6 @@ def register(self, plugin: _PluggyPlugin, name: str | None = None) -> str | None
self.consider_module(plugin)
return plugin_name

def getplugin(self, name: str):
# Support deprecated naming because plugins (xdist e.g.) use it.
plugin: _PluggyPlugin | None = self.get_plugin(name)
return plugin

def hasplugin(self, name: str) -> bool:
"""Return whether a plugin with the given name is registered."""
return bool(self.get_plugin(name))
Expand Down
6 changes: 3 additions & 3 deletions src/_pytest/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _init_pdb(cls, method, *args, **kwargs):
if cls._pluginmanager is None:
capman: CaptureManager | None = None
else:
capman = cls._pluginmanager.getplugin("capturemanager")
capman = cls._pluginmanager.get_plugin("capturemanager")
if capman:
capman.suspend(in_=True)

Expand Down Expand Up @@ -287,7 +287,7 @@ class PdbInvoke:
def pytest_exception_interact(
self, node: Node, call: CallInfo[Any], report: BaseReport
) -> None:
capman = node.config.pluginmanager.getplugin("capturemanager")
capman = node.config.pluginmanager.get_plugin("capturemanager")
if capman:
capman.suspend_global_capture(in_=True)
out, err = capman.read_global_capture()
Expand Down Expand Up @@ -340,7 +340,7 @@ def _enter_pdb(
# XXX we reuse the TerminalReporter's terminalwriter
# because this seems to avoid some encoding related troubles
# for not completely clear reasons.
tw = node.config.pluginmanager.getplugin("terminalreporter")._tw
tw = node.config.pluginmanager.get_plugin("terminalreporter")._tw
tw.line()

showcapture = node.config.option.showcapture
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def _disable_output_capturing_for_darwin(self) -> None:
"""Disable output capturing. Otherwise, stdout is lost to doctest (#985)."""
if platform.system() != "Darwin":
return
capman = self.config.pluginmanager.getplugin("capturemanager")
capman = self.config.pluginmanager.get_plugin("capturemanager")
if capman:
capman.suspend_global_capture(in_=True)
out, err = capman.read_global_capture()
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/pastebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def pytest_configure(config: Config) -> None:
config.issue_config_time_warning(PASTEBIN.format(), 2)

if config.option.pastebin == "all":
tr = config.pluginmanager.getplugin("terminalreporter")
tr = config.pluginmanager.get_plugin("terminalreporter")
# If no terminal reporter plugin is present, nothing we can do here;
# this can happen when this function executes in a worker node
# when using pytest-xdist, for example.
Expand All @@ -65,7 +65,7 @@ def pytest_unconfigure(config: Config) -> None:
pastebinfile.close()
del config.stash[pastebinfile_key]
# Undo our patching in the terminal reporter.
tr = config.pluginmanager.getplugin("terminalreporter")
tr = config.pluginmanager.get_plugin("terminalreporter")
del tr._tw.__dict__["write"]
# Write summary.
tr.write_sep("=", "Sending information to Paste Service")
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/setuponly.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def pytest_fixture_post_finalizer(
def _show_fixture_action(
fixturedef: FixtureDef[object], config: Config, msg: str
) -> None:
capman = config.pluginmanager.getplugin("capturemanager")
capman = config.pluginmanager.get_plugin("capturemanager")
if capman:
capman.suspend_global_capture()

Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/subtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def __exit__(
def capturing_output(request: SubRequest) -> Iterator[Captured]:
option = request.config.getoption("capture", None)

capman = request.config.pluginmanager.getplugin("capturemanager")
capman = request.config.pluginmanager.get_plugin("capturemanager")
if getattr(capman, "_capture_fixture", None):
# capsys or capfd are active, subtest should not capture.
fixture = None
Expand Down Expand Up @@ -318,7 +318,7 @@ def capturing_output(request: SubRequest) -> Iterator[Captured]:
def capturing_logs(
request: SubRequest,
) -> Iterator[CapturedLogs | None]:
logging_plugin: LoggingPlugin | None = request.config.pluginmanager.getplugin(
logging_plugin: LoggingPlugin | None = request.config.pluginmanager.get_plugin(
"logging-plugin"
)
if logging_plugin is None:
Expand Down
8 changes: 4 additions & 4 deletions testing/logging/test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def test_ini_controls_global_log_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_level_override(request, caplog):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_level == logging.ERROR
logger = logging.getLogger('catchlog')
logger.warning("WARNING message won't be shown")
Expand Down Expand Up @@ -413,7 +413,7 @@ def test_can_override_global_log_level(pytester: Pytester) -> None:
import logging
def test_log_level_override(request, caplog):
logger = logging.getLogger('catchlog')
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_level == logging.WARNING

logger.info("INFO message won't be shown")
Expand Down Expand Up @@ -479,7 +479,7 @@ def test_captures_despite_exception(pytester: Pytester) -> None:
import logging
def test_log_level_override(request, caplog):
logger = logging.getLogger('catchlog')
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_level == logging.WARNING

logger.error("ERROR message " + "will be shown")
Expand Down Expand Up @@ -522,7 +522,7 @@ def function_that_logs():
print('Print ' + 'message')

def test_that_fails(request, caplog):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_level == logging.INFO

with caplog.at_level(logging.DEBUG):
Expand Down
20 changes: 10 additions & 10 deletions testing/logging/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_log_cli_default_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_cli(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_cli_handler.level == logging.NOTSET
logging.getLogger('catchlog').info("INFO message won't be shown")
logging.getLogger('catchlog').warning("WARNING message will be shown")
Expand Down Expand Up @@ -551,7 +551,7 @@ def test_log_cli_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_cli(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_cli_handler.level == logging.INFO
logging.getLogger('catchlog').debug("This log message won't be shown")
logging.getLogger('catchlog').info("This log message will be shown")
Expand Down Expand Up @@ -607,7 +607,7 @@ def test_log_cli_ini_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_cli(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_cli_handler.level == logging.INFO
logging.getLogger('catchlog').debug("This log message won't be shown")
logging.getLogger('catchlog').info("This log message will be shown")
Expand Down Expand Up @@ -685,7 +685,7 @@ def test_log_file_cli(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.WARNING
logging.getLogger('catchlog').info("This log message won't be shown")
logging.getLogger('catchlog').warning("This log message will be shown")
Expand Down Expand Up @@ -718,7 +718,7 @@ def test_log_file_mode_cli(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.WARNING
logging.getLogger('catchlog').info("This log message won't be shown")
logging.getLogger('catchlog').warning("This log message will be shown")
Expand Down Expand Up @@ -758,7 +758,7 @@ def test_log_file_mode_cli_invalid(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.WARNING
logging.getLogger('catchlog').info("This log message won't be shown")
logging.getLogger('catchlog').warning("This log message will be shown")
Expand All @@ -785,7 +785,7 @@ def test_log_file_cli_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.INFO
logging.getLogger('catchlog').debug("This log message won't be shown")
logging.getLogger('catchlog').info("This log message will be shown")
Expand Down Expand Up @@ -836,7 +836,7 @@ def test_log_file_ini(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.WARNING
logging.getLogger('catchlog').info("This log message won't be shown")
logging.getLogger('catchlog').warning("This log message will be shown")
Expand Down Expand Up @@ -874,7 +874,7 @@ def test_log_file_mode_ini(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.WARNING
logging.getLogger('catchlog').info("This log message won't be shown")
logging.getLogger('catchlog').warning("This log message will be shown")
Expand Down Expand Up @@ -914,7 +914,7 @@ def test_log_file_ini_level(pytester: Pytester) -> None:
import pytest
import logging
def test_log_file(request):
plugin = request.config.pluginmanager.getplugin('logging-plugin')
plugin = request.config.pluginmanager.get_plugin('logging-plugin')
assert plugin.log_file_handler.level == logging.INFO
logging.getLogger('catchlog').debug("This log message won't be shown")
logging.getLogger('catchlog').info("This log message will be shown")
Expand Down
2 changes: 1 addition & 1 deletion testing/python/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
"""
)
item = pytester.getitem("def test_func(): pass")
item.config.pluginmanager.getplugin("runner")
item.config.pluginmanager.get_plugin("runner")
assert item.location == ("ABCDE", 42, "custom")

def test_func_reportinfo(self, pytester: Pytester) -> None:
Expand Down
2 changes: 1 addition & 1 deletion testing/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ def test_libedit_workaround(pytester: Pytester) -> None:


def pytest_terminal_summary(config):
capture = config.pluginmanager.getplugin("capturemanager")
capture = config.pluginmanager.get_plugin("capturemanager")
capture.suspend_global_capture(in_=True)

print("Enter 'hi'")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ def my_dists():
)
monkeypatch.setenv("PYTEST_PLUGINS", "mytestplugin")
config = pytester.parseconfig()
plugin = config.pluginmanager.getplugin("mytestplugin")
plugin = config.pluginmanager.get_plugin("mytestplugin")
assert plugin.x == 42


Expand Down
2 changes: 1 addition & 1 deletion testing/test_debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def pdblist(self, request):
def mypdb(*args):
pdblist.append(args)

plugin = request.config.pluginmanager.getplugin("debugging")
plugin = request.config.pluginmanager.get_plugin("debugging")
monkeypatch.setattr(plugin, "post_mortem", mypdb)
return pdblist

Expand Down
4 changes: 2 additions & 2 deletions testing/test_pastebin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestPasteCapture:
@pytest.fixture
def pastebinlist(self, monkeypatch, request) -> list[str | bytes]:
pastebinlist: list[str | bytes] = []
plugin = request.config.pluginmanager.getplugin("pastebin")
plugin = request.config.pluginmanager.get_plugin("pastebin")
monkeypatch.setattr(plugin, "create_new_paste", pastebinlist.append)
return pastebinlist

Expand Down Expand Up @@ -106,7 +106,7 @@ def test_deprecated(self, pytester: Pytester, pastebinlist) -> None:
class TestPaste:
@pytest.fixture
def pastebin(self, request):
return request.config.pluginmanager.getplugin("pastebin")
return request.config.pluginmanager.get_plugin("pastebin")

@pytest.fixture
def mocked_urlopen_invalid(self, monkeypatch: MonkeyPatch):
Expand Down
2 changes: 1 addition & 1 deletion testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ def test_terminalreporter_reportopt_addopts(pytester: Pytester) -> None:

@pytest.fixture
def tr(request):
tr = request.config.pluginmanager.getplugin("terminalreporter")
tr = request.config.pluginmanager.get_plugin("terminalreporter")
return tr
def test_opt(tr):
assert tr.hasopt('skipped')
Expand Down
Loading