Skip to content

Commit

Permalink
Add duration, platform and version information to test results data s…
Browse files Browse the repository at this point in the history
…tructure.
  • Loading branch information
ntoll committed Sep 11, 2024
1 parent 30d84de commit 8d2020f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@
# in "skipped".
for test_run, result in actual_results.items(): # result_all, result_module, etc.
for test_status, matching_tests in result.items(): # passes, fails, skipped
for test in matching_tests:
assert test["test_name"].endswith(
test_status
), f"Test {test["test_name"]} does not end with {test_status}"
if test_status in ["passes", "fails", "skipped"]:
for test in matching_tests:
assert test["test_name"].endswith(
test_status
), f"Test {test["test_name"]} does not end with {test_status}"

# Create a div to display the results in the page.
page.append(
Expand Down
7 changes: 5 additions & 2 deletions upytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,17 @@ async def run(*args, **kwargs):
error_count = len(failed_tests)
skip_count = len(skipped_tests)
pass_count = test_count - error_count - skip_count
dur = end - start
duration = end - start
print(
"========================= short test summary info =========================="
)
print(
f"\033[1m{error_count}\033[0m \033[31;1mfailed\033[0m, \033[1m{skip_count}\033[0m \033[33;1mskipped\033[0m, \033[1m{pass_count}\033[0m \033[32;1mpassed\033[0m in \033[1m{dur:.2f} seconds\033[0m"
f"\033[1m{error_count}\033[0m \033[31;1mfailed\033[0m, \033[1m{skip_count}\033[0m \033[33;1mskipped\033[0m, \033[1m{pass_count}\033[0m \033[32;1mpassed\033[0m in \033[1m{duration:.2f} seconds\033[0m"
)
return {
"duration": duration,
"platform": sys.platform,
"version": sys.version,
"passes": [test.as_dict for test in passed_tests],
"fails": [test.as_dict for test in failed_tests],
"skipped": [test.as_dict for test in skipped_tests],
Expand Down

0 comments on commit 8d2020f

Please sign in to comment.