Skip to content

Commit 23bda2b

Browse files
Greg BrooksGregox273
authored andcommitted
Add tests (#1956)
1 parent 4eb90f6 commit 23bda2b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/test_util.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,28 @@ def test_bit_timing_fd_cfg(self):
209209
assert timing.data_tseg2 == 10
210210
assert timing.data_sjw == 10
211211

212+
def test_state_with_str(self):
213+
can_cfg = _create_bus_config(
214+
{
215+
**self.base_config,
216+
"state": "PASSIVE",
217+
}
218+
)
219+
state = can_cfg["state"]
220+
assert isinstance(state, can.BusState)
221+
assert state == can.BusState.PASSIVE
222+
223+
def test_state_with_enum(self):
224+
expected_state = can.BusState.PASSIVE
225+
can_cfg = _create_bus_config(
226+
{
227+
**self.base_config,
228+
"state": expected_state,
229+
}
230+
)
231+
state = can_cfg["state"]
232+
assert isinstance(state, can.BusState)
233+
assert state == expected_state
212234

213235
class TestChannel2Int(unittest.TestCase):
214236
def test_channel2int(self) -> None:

0 commit comments

Comments
 (0)