mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 20:33:54 +08:00
Unittest to pytest (#32366)
* add pytest-asyncio * switch common * switch selfdrive * switch system * switch tools * small fixes * fix setUp and valgrind pytest * switch to setup * fix random * switch mock * switch test_lateral_limits * revert test_ui * fix poetry.lock * add unittest to banned-api * add inline ignores to remaining unittest imports * revert test_models * revert check_can_parser_performance * one more skip --------- Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
@@ -4,7 +4,6 @@ import glob
|
||||
import signal
|
||||
import subprocess
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.common.timeout import Timeout
|
||||
@@ -12,7 +11,7 @@ from openpilot.tools.plotjuggler.juggle import DEMO_ROUTE, install
|
||||
|
||||
PJ_DIR = os.path.join(BASEDIR, "tools/plotjuggler")
|
||||
|
||||
class TestPlotJuggler(unittest.TestCase):
|
||||
class TestPlotJuggler:
|
||||
|
||||
def test_demo(self):
|
||||
install()
|
||||
@@ -28,13 +27,13 @@ class TestPlotJuggler(unittest.TestCase):
|
||||
|
||||
# ensure plotjuggler didn't crash after exiting the plugin
|
||||
time.sleep(15)
|
||||
self.assertEqual(p.poll(), None)
|
||||
assert p.poll() is None
|
||||
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
|
||||
|
||||
self.assertNotIn("Raw file read failed", output)
|
||||
assert "Raw file read failed" not in output
|
||||
|
||||
# TODO: also test that layouts successfully load
|
||||
def test_layouts(self):
|
||||
def test_layouts(self, subtests):
|
||||
bad_strings = (
|
||||
# if a previously loaded file is defined,
|
||||
# PJ will throw a warning when loading the layout
|
||||
@@ -43,12 +42,8 @@ class TestPlotJuggler(unittest.TestCase):
|
||||
)
|
||||
for fn in glob.glob(os.path.join(PJ_DIR, "layouts/*")):
|
||||
name = os.path.basename(fn)
|
||||
with self.subTest(layout=name):
|
||||
with subtests.test(layout=name):
|
||||
with open(fn) as f:
|
||||
layout = f.read()
|
||||
violations = [s for s in bad_strings if s in layout]
|
||||
assert len(violations) == 0, f"These should be stripped out of the layout: {str(violations)}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user