Skip to content

Commit

Permalink
Fix usage of deprecated startdir parameter
Browse files Browse the repository at this point in the history
Use the start_path parameter instead of startdir for Pytest 7 or newer,
since Pytest 7 yields the following deprecation warning if startdir is
being used:

    site-packages/pytest_sugar.py:279: PytestRemovedIn8Warning:
    The (startdir: py.path.local) argument is deprecated, please
    use (start_path: pathlib.Path)

Details of the Pytest deprecation can be found from:
https://docs.pytest.org/en/latest/deprecations.html#py-path-local-arguments-for-hooks-replaced-with-pathlib-path

Fixes #232
  • Loading branch information
suutari-ai committed Jan 24, 2024
1 parent bcfb953 commit 3841533
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pytest_sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,12 @@ def pytest_sessionstart(self, session: Session) -> None:
),
bold=True,
)
if pytest.__version__.split(".")[0] <= "6":
hook_call_kwargs = {"startdir": self.startpath}
else:
hook_call_kwargs = {"start_path": self.startpath}
lines = self.config.hook.pytest_report_header(
config=self.config, startdir=self.startpath
config=self.config, **hook_call_kwargs
)
lines.reverse()
for line in flatten(lines):
Expand Down

0 comments on commit 3841533

Please sign in to comment.