forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch cereal to pytest (commaai#32950)
pytest
- Loading branch information
1 parent
35df0a4
commit 133f25e
Showing
4 changed files
with
45 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import tempfile | ||
from typing import Dict | ||
import unittest | ||
from parameterized import parameterized | ||
|
||
import cereal.services as services | ||
from cereal.services import SERVICE_LIST | ||
|
||
|
||
class TestServices(unittest.TestCase): | ||
class TestServices: | ||
|
||
@parameterized.expand(SERVICE_LIST.keys()) | ||
def test_services(self, s): | ||
service = SERVICE_LIST[s] | ||
self.assertTrue(service.frequency <= 104) | ||
self.assertTrue(service.decimation != 0) | ||
assert service.frequency <= 104 | ||
assert service.decimation != 0 | ||
|
||
def test_generated_header(self): | ||
with tempfile.NamedTemporaryFile(suffix=".h") as f: | ||
ret = os.system(f"python3 {services.__file__} > {f.name} && clang++ {f.name}") | ||
self.assertEqual(ret, 0, "generated services header is not valid C") | ||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
assert ret == 0, "generated services header is not valid C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters