def test_recv_error_with_partial_payload(self):
     socket = FakeReadableSocket(b'\x05abc', True)
     self.assertIsNone(m1proto.recv(socket))
 def test_recv_error(self):
     socket = FakeReadableSocket(b'', True)
     self.assertIsNone(m1proto.recv(socket))
 def test_recv_error_after_first_byte(self):
     socket = FakeReadableSocket(b'\x05', True)
     self.assertIsNone(m1proto.recv(socket))
 def test_recv_end(self):
     socket = FakeReadableSocket(b'')
     self.assertIsNone(m1proto.recv(socket))
 def test_recv_max(self):
     socket = FakeReadableSocket(b'\xFF' + (b'x' * 254) + b'X')
     self.assertEqual(m1proto.recv(socket), ('x' * 254) + 'X')
 def test_recv_unicode(self):
     socket = FakeReadableSocket(b'\x02\xC2\xA0')
     self.assertEqual(m1proto.recv(socket), '\xA0')
 def test_recv_ascii(self):
     socket = FakeReadableSocket(b'\x03abc')
     self.assertEqual(m1proto.recv(socket), 'abc')
 def test_recv_empty(self):
     socket = FakeReadableSocket(b'\0')
     self.assertEqual(m1proto.recv(socket), '')