Skip to content

Commit

Permalink
restrict execution notes length (#23)
Browse files Browse the repository at this point in the history
 imit note length to 1000 characters by default.
Can be configured using env variable
  • Loading branch information
jupe authored May 18, 2022
1 parent e070c4c commit 2d1f282
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Running with pytest:
`pytest --opentmi <host> --opentmi_token <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.
Expand Down
9 changes: 9 additions & 0 deletions pytest_opentmi/OpenTmiReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ''
Expand All @@ -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:
Expand Down

0 comments on commit 2d1f282

Please sign in to comment.