numirias / pytest-json-report

🗒️ A pytest plugin to report test results as JSON
MIT License
147 stars 39 forks source link

pytest_warning_captured deprecated in pytest 6 #55

Closed okken closed 4 years ago

okken commented 4 years ago

The plugin uses pytest_warning_captured, which was deprecated in pytest 6. https://docs.pytest.org/en/stable/reference.html#pytest.hookspec.pytest_warning_captured

Looks like there's a new hook, pytest_warning_recorded, with similar enough API: https://docs.pytest.org/en/stable/reference.html#pytest.hookspec.pytest_warning_recorded

okken commented 4 years ago

I asked the pytest mailing list for options on how to deal with this.

Got this from Bruno Oliveira: "...

An alternative is to check if the new hook exists, like how we used to do in pytest-xdist:

https://github.com/pytest-dev/pytest-xdist/blob/7bf654775dcd2fef9c0ebafbea982b7d180b740e/src/xdist/remote.py#L142-L164

Where we implement one hook or the other, giving preference to the new hook when available. ... "

I think the xdist fix would work for pytest-json-report

numirias commented 4 years ago

Thanks for the instructive report! Patched in the latest release.