From 30c407127b12bcdfc7afce2449aa3811e8da3e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Sat, 17 Aug 2024 20:03:45 +0200 Subject: [PATCH] Add test for SdoRecord length and iteration count. --- test/test_sdo.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test_sdo.py b/test/test_sdo.py index 8b445986..d931ca9e 100644 --- a/test/test_sdo.py +++ b/test/test_sdo.py @@ -20,6 +20,15 @@ def setUp(self): node = canopen.LocalNode(1, SAMPLE_EDS) self.sdo_node = node.sdo + def test_record_iter_length(self): + """Assume the "highest subindex supported" entry is not counted. + + Sub-objects without an OD entry should be skipped as well.""" + record = self.sdo_node[0x1018] + subs = sum(1 for _ in iter(record)) + self.assertEqual(len(record), 3) + self.assertEqual(subs, 3) + def test_array_iter_length(self): """Assume the "highest subindex supported" entry is not counted.""" array = self.sdo_node[0x1003]