-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: questiongeneral question, might be closed after 2 weeks of inactivitygeneral question, might be closed after 2 weeks of inactivity
Description
We have a custom report class defined which uses the pytest_runtest_logreport
hook to handle test results, and to build a test report based on our needs. For one of the reports only the exception message is used as summary. Sadly the passed in report
instance for pytest_runtest_logreport
doesn't contain such a property. Instead report.longreprtext
has to be used (which includes the full stack trace) to extract just the error line:
class SubtestResultRecorder(object):
def __init__(self):
self.results = []
def pytest_runtest_logreport(self, report):
if report.failed && report.when != "call":
message = ""
for line in report.longreprtext.splitlines():
if line.startswith("E "):
message = line[1:].strip()
break
[...]
This doesn't seem to be very stable and might break if pytest changes the formatting.
So it would be great if there could be a property like report.exc_message
which would hold only the assertion message.
Metadata
Metadata
Assignees
Labels
topic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: questiongeneral question, might be closed after 2 weeks of inactivitygeneral question, might be closed after 2 weeks of inactivity