@@ 177-187 (lines=11) @@ | ||
174 | """Test an empty Message.""" |
|
175 | ||
176 | val = Message('test', []) |
|
177 | self.assertEqual(val._tuple._fields, ()) # pylint: disable=protected-access |
|
178 | ||
179 | def test_pack_little_endian(self): |
|
180 | """Test pack the test formats.""" |
|
181 | test_msg = Message('test', self.teststruct, Mode.Little) |
|
182 | for idx in range(len(self.testvalues)): |
|
183 | with self.subTest(idx): # pylint: disable=no-member |
|
184 | packed_msg = test_msg.pack(**self.testvalues[idx]) |
|
185 | self.assertEqual(self.testbytes['little'][idx], packed_msg) |
|
186 | ||
187 | def test_unpack_little_endian(self): |
|
188 | """Test unpack the test formats.""" |
|
189 | test_msg = Message('test', self.teststruct, Mode.Little) |
|
190 | for idx in range(len(self.testvalues)): |
|
@@ 157-167 (lines=11) @@ | ||
154 | ||
155 | def test_init_invalid_name(self): |
|
156 | """Test invalid Message names.""" |
|
157 | ||
158 | for name in [None, '', 1, dict(), list()]: |
|
159 | with self.subTest(name): # pylint: disable=no-member |
|
160 | with self.assertRaises(TypeError) as cm: |
|
161 | Message(name, self.teststruct) |
|
162 | self.assertEqual(str(cm.exception), 'invalid name: {}'.format(name)) |
|
163 | ||
164 | def test_init_invalid_mode(self): |
|
165 | """Test invalid Message modes.""" |
|
166 | ||
167 | for mode in ['=', 'stuff', 0, -1, 1]: |
|
168 | with self.subTest(mode): # pylint: disable=no-member |
|
169 | with self.assertRaises(TypeError) as cm: |
|
170 | Message('test', self.teststruct, mode) |