JetBrains / teamcity-messages

Python Unit Test Reporting to TeamCity
https://pypi.python.org/pypi/teamcity-messages
Apache License 2.0
136 stars 81 forks source link

PyTest: report crashing tests as failed #255

Open octachrome opened 2 years ago

octachrome commented 2 years ago

This change ensures that a test which crashes is reported to TeamCity as failed.

When using PyTest with the pytest-xdist plugin and one of the --forked, --boxed or -n options, tests will execute in Python subprocesses, which means individual tests can crash without crashing the main PyTest process. In case of a crash, the pytest_runtest_logreport hook is called with report.failed == True and report.when == '???' (undocumented behaviour). This PR modifies the TeamCity PyTest plugin to handle this case.

Example output:

##teamcity[testFailed timestamp='2021-08-10T14:39:37.427' details=':-1: running the test CRASHED with signal 11' flowId='Test.test_crash.test_fail' message='Test/test_crash.py:0 (test_fail)' name='Test.test_crash.test_fail']