test_power_draw: add header to output table (#27511)

* test_power_draw: add header to output table

* units
old-commit-hash: ebd25b8a7d
beeps
Adeeb Shihadeh 2 years ago committed by GitHub
parent 2fe836f158
commit 37af774ab0
  1. 4
      poetry.lock
  2. 1
      pyproject.toml
  3. 10
      system/hardware/tici/test_power_draw.py

4
poetry.lock generated

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d8ca18a4f67bb8e2d77276da5f20381263fd62a5a8ff7d08a8c387ba7952a1c4
size 587143
oid sha256:70c04e16e6d385d5b589799946aafa4d25382137083c4558fbdd03e00ddd2327
size 585015

@ -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]

@ -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__":

Loading…
Cancel
Save