Skip to content

Commit 07855c8

Browse files
committed
Add unittest for timing conf
1 parent 558b297 commit 07855c8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/test_util.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import unittest
22
import warnings
33

4-
from can.util import _rename_kwargs
4+
from can.util import _create_bus_config, _rename_kwargs
55

66

77
class RenameKwargsTest(unittest.TestCase):
@@ -47,3 +47,18 @@ def test_with_new_and_alias_present(self):
4747
aliases = {"old_a": "a", "old_b": "b", "z": None}
4848
with self.assertRaises(TypeError):
4949
self._test(kwargs, aliases)
50+
51+
52+
class TestBusConfig(unittest.TestCase):
53+
base_config = dict(interface="socketcan", bitrate=500_000)
54+
55+
def test_timing_can_use_int(self):
56+
"""
57+
Test that an exception is not raised when using
58+
integers for timing values in config.
59+
"""
60+
timing_conf = dict(tseg1=5, tseg2=10, sjw=25)
61+
try:
62+
_create_bus_config({**self.base_config, **timing_conf})
63+
except TypeError as e:
64+
self.fail(e)

0 commit comments

Comments
 (0)