diff options
author | Friedemann Kleint <[email protected]> | 2025-07-07 13:36:37 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2025-07-09 10:36:40 +0200 |
commit | 8c5896ca00e23fbfba4ddc07b48dc051c0c2913c (patch) | |
tree | c95b0cea0d4e34063dde701a4eae48eafc23b965 /testing/parser.py | |
parent | aec72ac51d8c8649b252622ea316b8dd0bcd1ad7 (diff) |
testrunner.py: Use dataclass instead of a named tuple
Pick-to: 6.9
Change-Id: I229822c8b548a19332a91768e0e250d1e4182484
Reviewed-by: Shyamnath Premnadh <[email protected]>
Diffstat (limited to 'testing/parser.py')
-rw-r--r-- | testing/parser.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/testing/parser.py b/testing/parser.py index abf00ef3f..c41c0a231 100644 --- a/testing/parser.py +++ b/testing/parser.py @@ -4,7 +4,7 @@ from __future__ import annotations import os import re -from collections import namedtuple +from dataclasses import dataclass from io import StringIO """ @@ -70,9 +70,18 @@ assert re.match(_TEST_PAT, _EXAMPLE.splitlines()[5], re.VERBOSE) assert len(re.match(_TEST_PAT, _EXAMPLE.splitlines()[5], re.VERBOSE).groups()) == 8 assert len(re.match(_TEST_PAT, _EXAMPLE.splitlines()[7], re.VERBOSE).groups()) == 8 -TestResult = namedtuple( - "TestResult", "idx n sharp mod_name passed " "code time fatal rich_result".split() -) + +@dataclass +class TestResult: + idx: int = 0 + n: int = 0 + sharp: int = 0 + mod_name: str = "" + passed: bool = False + code: str = "" + time: float = 0 + fatal: bool = False + rich_result: str = "" def _parse_tests(test_log): @@ -114,9 +123,9 @@ def _parse_tests(test_log): if idx + 1 != item.idx: # The numbering is disrupted. Provoke an error in this line! code = f"{code}, but lines are disrupted!" - result[idx] = item._replace( - passed=False, code=f"{item.code}, but lines are disrupted!", fatal=True - ) + result[idx].passed = False + result[idx].code = f"{item.code}, but lines are disrupted!" + result[idx].fatal = True break return result @@ -150,4 +159,5 @@ class TestParser: if item.fatal: # PYSIDE-1229: Stop the testing completely when a fatal error exists res = "FATAL" - yield item._replace(rich_result=res) + item.rich_result = res + yield item |