[#165] Fix test flow in case of skipped tests

Signed-off-by: Andrey Berezin <a.berezin@yadro.com>
master
Andrey Berezin 2023-12-05 11:33:59 +03:00
parent f6438c5b93
commit 71bb73a410
1 changed files with 6 additions and 1 deletions

View File

@ -69,6 +69,7 @@ def pytest_collection_finish(session: pytest.Session):
for number, item in enumerate(session.items, 1):
item.stash[number_key] = f"[{number}/{items_total}]"
item.stash[test_outcome] = ""
item.stash[start_time] = 0
# pytest hook. Do not rename
@ -80,7 +81,11 @@ def pytest_runtest_setup(item: pytest.Item):
# pytest hook. Do not rename
def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo):
if call.excinfo is not None:
item.stash[test_outcome] += f"FAILED on {call.when}; "
if call.excinfo.typename == "Skipped":
item.stash[start_time] = int(datetime.now().timestamp())
item.stash[test_outcome] += f"SKIPPED on {call.when}; "
else:
item.stash[test_outcome] += f"FAILED on {call.when}; "
if call.when == "teardown":
duration = int(datetime.now().timestamp()) - item.stash[start_time]