Rename pytest_report_header startpath parameter to start_path

This commit is contained in:
Bruno Oliveira 2021-12-01 17:56:06 -03:00
parent 5288588971
commit f72efb6ed8
4 changed files with 7 additions and 7 deletions

View File

@ -13,7 +13,7 @@ imply_paths_hooks = {
"pytest_ignore_collect": ("collection_path", "path"), "pytest_ignore_collect": ("collection_path", "path"),
"pytest_collect_file": ("file_path", "path"), "pytest_collect_file": ("file_path", "path"),
"pytest_pycollect_makemodule": ("module_path", "path"), "pytest_pycollect_makemodule": ("module_path", "path"),
"pytest_report_header": ("startpath", "startdir"), "pytest_report_header": ("start_path", "startdir"),
"pytest_report_collectionfinish": ("startpath", "startdir"), "pytest_report_collectionfinish": ("startpath", "startdir"),
} }

View File

@ -674,12 +674,12 @@ def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> No
def pytest_report_header( def pytest_report_header(
config: "Config", startpath: Path, startdir: "LEGACY_PATH" config: "Config", start_path: Path, startdir: "LEGACY_PATH"
) -> Union[str, List[str]]: ) -> Union[str, List[str]]:
"""Return a string or list of strings to be displayed as header info for terminal reporting. """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 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). :param LEGACY_PATH startdir: The starting dir (deprecated).
.. note:: .. note::
@ -696,7 +696,7 @@ def pytest_report_header(
:ref:`discovers plugins during startup <pluginorder>`. :ref:`discovers plugins during startup <pluginorder>`.
.. versionchanged:: 7.0.0 .. 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 equivalent of the ``startdir`` parameter. The ``startdir`` parameter
has been deprecated. has been deprecated.
""" """

View File

@ -702,7 +702,7 @@ class TerminalReporter:
msg += " -- " + str(sys.executable) msg += " -- " + str(sys.executable)
self.write_line(msg) self.write_line(msg)
lines = self.config.hook.pytest_report_header( 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) self._write_report_lines_from_hooks(lines)

View File

@ -1461,8 +1461,8 @@ class TestGenericReporting:
) )
pytester.mkdir("a").joinpath("conftest.py").write_text( pytester.mkdir("a").joinpath("conftest.py").write_text(
""" """
def pytest_report_header(config, startpath): def pytest_report_header(config, start_path):
return ["line1", str(startpath)] return ["line1", str(start_path)]
""" """
) )
result = pytester.runpytest("a") result = pytester.runpytest("a")