From 2d1f2822235716f8aab935fd271597f70d6bb439 Mon Sep 17 00:00:00 2001 From: Jussi Vatjus-Anttila Date: Wed, 18 May 2022 12:41:22 +0300 Subject: [PATCH] restrict execution notes length (#23) imit note length to 1000 characters by default. Can be configured using env variable --- README.md | 4 ++++ pytest_opentmi/OpenTmiReport.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index cbd9fff..00afbb9 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ Running with pytest: `pytest --opentmi --opentmi_token [--opentmi_store_logs]` +### Configuration + +* env variable `OPENTMI_MAX_EXEC_NOTE_LENGTH` can be used to cut long failure notes. Default 1000 characters. + ### metadata module utilize some special pytest metadata keys. diff --git a/pytest_opentmi/OpenTmiReport.py b/pytest_opentmi/OpenTmiReport.py index 8120c48..5ca2d3d 100644 --- a/pytest_opentmi/OpenTmiReport.py +++ b/pytest_opentmi/OpenTmiReport.py @@ -19,6 +19,9 @@ class OpenTmiReport: """ OpenTmiReport class """ + + MAX_EXEC_NOTE_LENGTH: int = int(os.environ.get('OPENTMI_MAX_EXEC_NOTE_LENGTH', '1000')) + def __init__(self, config): """ Constructor @@ -254,6 +257,11 @@ def _new_result(self, report): return result + @staticmethod + def _cut_long_note(result: Result): + if result.execution.note: + result.execution.note = result.execution.note[:OpenTmiReport.MAX_EXEC_NOTE_LENGTH] + def _link_session(self, session, result): # pylint: disable=unused-argument # dut = Dut() # dut.serial_number = '' @@ -264,6 +272,7 @@ def _link_session(self, session, result): # pylint: disable=unused-argument numtests=self._numtests ) result.execution.profiling['generated_at'] = self._generated.isoformat() + OpenTmiReport._cut_long_note(result) def _upload_report(self, result: Result): try: