We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logging.raiseExceptions
minimal example:
import logging from unittest import mock class Boom: def __str__(self) -> str: raise ValueError('nope!') @mock.patch.object(logging, "raiseExceptions", False) def test_does_not_error(): logging.error(Boom())
passes without:
$ pytest -qq t.py . [100%]
fails with:
$ pytest -qq t.py --json-report --json-report-file out.json F [100%] =================================== FAILURES =================================== _____________________________ test_does_not_error ______________________________ @mock.patch.object(logging, "raiseExceptions", False) def test_does_not_error(): > logging.error(Boom()) t.py:10: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:2190: in error root.error(msg, *args, **kwargs) /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:1568: in error self._log(ERROR, msg, args, **kwargs) /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:1684: in _log self.handle(record) /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:1700: in handle self.callHandlers(record) /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:1762: in callHandlers hdlr.handle(record) /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:1028: in handle self.emit(record) venv/lib/python3.12/site-packages/pytest_jsonreport/plugin.py:319: in emit d['msg'] = record.getMessage() /opt/homebrew/Cellar/[email protected]/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/logging/__init__.py:390: in getMessage msg = str(self.msg) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <t.Boom object at 0x10558b110> def __str__(self) -> str: > raise ValueError('nope!') E ValueError: nope! t.py:6: ValueError =========================== short test summary info ============================ FAILED t.py::test_does_not_error - ValueError: nope!
it would seem that pytest-json-report's logging handler needs something similar to the stdlib's:
pytest-json-report
https://github.com/python/cpython/blob/6150bb2412eb5ca3b330ccb9f0636949c7526a7f/Lib/logging/__init__.py#L1141-L1150
a workaround appears to be to disable the log component:
$ pytest -qq t.py --json-report --json-report-file out.json --json-report-omit log . [100%]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
minimal example:
passes without:
fails with:
it would seem that
pytest-json-report
's logging handler needs something similar to the stdlib's:https://github.com/python/cpython/blob/6150bb2412eb5ca3b330ccb9f0636949c7526a7f/Lib/logging/__init__.py#L1141-L1150
a workaround appears to be to disable the log component:
The text was updated successfully, but these errors were encountered: