mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
chore(core): add colors to unittest prints
[no changelog]
This commit is contained in:
parent
ea1c32f90e
commit
0d7fe7d643
@ -2,6 +2,10 @@ import sys
|
|||||||
|
|
||||||
from trezor.utils import ensure
|
from trezor.utils import ensure
|
||||||
|
|
||||||
|
DEFAULT_COLOR = "\033[0m"
|
||||||
|
ERROR_COLOR = "\033[31m"
|
||||||
|
OK_COLOR = "\033[32m"
|
||||||
|
|
||||||
|
|
||||||
class SkipTest(Exception):
|
class SkipTest(Exception):
|
||||||
pass
|
pass
|
||||||
@ -252,16 +256,16 @@ def run_class(c, test_result):
|
|||||||
raise RuntimeError(f"{name} should not return a result.")
|
raise RuntimeError(f"{name} should not return a result.")
|
||||||
finally:
|
finally:
|
||||||
tear_down()
|
tear_down()
|
||||||
print(" ok")
|
print(f"{OK_COLOR} ok{DEFAULT_COLOR}")
|
||||||
except SkipTest as e:
|
except SkipTest as e:
|
||||||
print(" skipped:", e.args[0])
|
print(" skipped:", e.args[0])
|
||||||
test_result.skippedNum += 1
|
test_result.skippedNum += 1
|
||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
print(" failed")
|
print(f"{ERROR_COLOR} failed{DEFAULT_COLOR}")
|
||||||
sys.print_exception(e)
|
sys.print_exception(e)
|
||||||
test_result.failuresNum += 1
|
test_result.failuresNum += 1
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
print(" errored:", e)
|
print(f"{ERROR_COLOR} errored:{DEFAULT_COLOR}", e)
|
||||||
sys.print_exception(e)
|
sys.print_exception(e)
|
||||||
test_result.errorsNum += 1
|
test_result.errorsNum += 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user