test_power_draw: add header to output table (#27511)

* test_power_draw: add header to output table

* units
old-commit-hash: ebd25b8a7de29542be7c6a213c578bc363999857
This commit is contained in:
Adeeb Shihadeh
2023-03-06 16:13:29 -08:00
committed by GitHub
parent 2fe836f158
commit 37af774ab0
3 changed files with 9 additions and 6 deletions

BIN
poetry.lock LFS generated

Binary file not shown.

View File

@@ -59,6 +59,7 @@ urllib3 = "^1.26.10"
utm = "^0.7.0"
websocket_client = "^1.3.3"
polyline = "^1.4.0"
types-tabulate = "^0.9.0.1"
[tool.poetry.group.dev.dependencies]

View File

@@ -3,6 +3,7 @@ import unittest
import time
import math
from dataclasses import dataclass
from tabulate import tabulate
from system.hardware import HARDWARE, TICI
from system.hardware.tici.power_monitor import get_power
@@ -58,15 +59,16 @@ class TestPowerDraw(unittest.TestCase):
manager_cleanup()
print("-"*35)
print(f"Baseline {baseline:.2f}W\n")
tab = []
tab.append(['process', 'expected (W)', 'current (W)'])
for proc in PROCS:
cur = used[proc.name]
expected = proc.power
print(f"{proc.name.ljust(20)} {expected:.2f}W {cur:.2f}W")
tab.append([proc.name, round(expected, 2), round(cur, 2)])
with self.subTest(proc=proc.name):
self.assertTrue(math.isclose(cur, expected, rel_tol=proc.rtol, abs_tol=proc.atol))
print("-"*35)
print(tabulate(tab))
print(f"Baseline {baseline:.2f}W\n")
if __name__ == "__main__":