def test_init(self): """Test constructor that creates object from stream.""" stream = ['\x01', '\x00', '\x03', '\x02', '\n', '\x00'] m = Message(stream) # Check properties self.assertEqual(m.cmd, 0x01) self.assertEqual(m.payload, [chr(2), chr(10), chr(0)]) # Convert message to stream self.assertEqual(m.stream, stream)
def test_small_message(self): """Test message with stream impossibly small.""" with self.assertRaises(SerialErrMsgShort): Message(['\x11', '\x00'])