From f72efb6ed8772d37609295eb02833881b25cfe47 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 1 Dec 2021 17:56:06 -0300 Subject: [PATCH] Rename pytest_report_header startpath parameter to start_path --- src/_pytest/config/compat.py | 2 +- src/_pytest/hookspec.py | 6 +++--- src/_pytest/terminal.py | 2 +- testing/test_terminal.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/_pytest/config/compat.py b/src/_pytest/config/compat.py index 88d0f23bb..67d1b9ec5 100644 --- a/src/_pytest/config/compat.py +++ b/src/_pytest/config/compat.py @@ -13,7 +13,7 @@ imply_paths_hooks = { "pytest_ignore_collect": ("collection_path", "path"), "pytest_collect_file": ("file_path", "path"), "pytest_pycollect_makemodule": ("module_path", "path"), - "pytest_report_header": ("startpath", "startdir"), + "pytest_report_header": ("start_path", "startdir"), "pytest_report_collectionfinish": ("startpath", "startdir"), } diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 59f9d11fc..09e2afd15 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -674,12 +674,12 @@ def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> No def pytest_report_header( - config: "Config", startpath: Path, startdir: "LEGACY_PATH" + config: "Config", start_path: Path, startdir: "LEGACY_PATH" ) -> Union[str, List[str]]: """Return a string or list of strings to be displayed as header info for terminal reporting. :param pytest.Config config: The pytest config object. - :param Path startpath: The starting dir. + :param Path start_path: The starting dir. :param LEGACY_PATH startdir: The starting dir (deprecated). .. note:: @@ -696,7 +696,7 @@ def pytest_report_header( :ref:`discovers plugins during startup `. .. versionchanged:: 7.0.0 - The ``startpath`` parameter was added as a :class:`pathlib.Path` + The ``start_path`` parameter was added as a :class:`pathlib.Path` equivalent of the ``startdir`` parameter. The ``startdir`` parameter has been deprecated. """ diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 057e89e6b..990e8a400 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -702,7 +702,7 @@ class TerminalReporter: msg += " -- " + str(sys.executable) self.write_line(msg) lines = self.config.hook.pytest_report_header( - config=self.config, startpath=self.startpath + config=self.config, start_path=self.startpath ) self._write_report_lines_from_hooks(lines) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 32f32ff5e..c1f0921fd 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1461,8 +1461,8 @@ class TestGenericReporting: ) pytester.mkdir("a").joinpath("conftest.py").write_text( """ -def pytest_report_header(config, startpath): - return ["line1", str(startpath)] +def pytest_report_header(config, start_path): + return ["line1", str(start_path)] """ ) result = pytester.runpytest("a")