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