tests: global constants (#889)

small clean up
This commit is contained in:
Shane Smiskol 2023-07-07 01:02:12 -07:00 committed by GitHub
parent b38a74af81
commit 33940105be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 14 deletions

View File

@ -0,0 +1,8 @@
import glob
import os
from opendbc import DBC_PATH
ALL_DBCS = [os.path.basename(dbc).split('.')[0] for dbc in
glob.glob(f"{DBC_PATH}/*.dbc")]
TEST_DBC = os.path.abspath(os.path.join(os.path.dirname(__file__), "test.dbc"))

View File

@ -5,6 +5,7 @@ import unittest
from opendbc.can.parser import CANParser, CANDefine
from opendbc.can.packer import CANPacker
class TestCanParserPackerExceptions(unittest.TestCase):
def test_civic_exceptions(self):
dbc_file = "honda_civic_touring_2016_can_generated"

View File

@ -1,19 +1,11 @@
#!/usr/bin/env python3
import glob
import os
import unittest
from opendbc import DBC_PATH
from opendbc.can.parser import CANParser
from opendbc.can.tests import ALL_DBCS
class TestDBCParser(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.dbcs = []
for dbc in glob.glob(f"{DBC_PATH}/*.dbc"):
cls.dbcs.append(os.path.basename(dbc).split('.')[0])
def test_parse_all_dbcs(self):
"""
Dynamic DBC parser checks:
@ -23,7 +15,7 @@ class TestDBCParser(unittest.TestCase):
- All BO_, SG_, VAL_ lines for syntax errors
"""
for dbc in self.dbcs:
for dbc in ALL_DBCS:
with self.subTest(dbc=dbc):
CANParser(dbc, [], [], 0)

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
import os
import unittest
import random
from functools import partial
@ -7,9 +6,7 @@ from functools import partial
import cereal.messaging as messaging
from opendbc.can.parser import CANParser
from opendbc.can.packer import CANPacker
TEST_DBC = os.path.abspath(os.path.join(os.path.dirname(__file__), "test.dbc"))
from opendbc.can.tests import TEST_DBC
# Python implementation so we don't have to depend on boardd