def test_double_eol(self): self._data = "the quick brown fox\n\njump over the lazy dog" client = TCPClientStream("127.0.0.1", 10000, eol="\n") res = [x for x in client.readline()] self.assertEqual(res, ["the quick brown fox", "", "jump over the lazy dog"])
def test_start_with_half_eol(self): self._data = "!the quick brown fox $! jump over the lazy dog" client = TCPClientStream("127.0.0.1", 10000, eol="$!") res = [x for x in client.readline()] self.assertEqual(res, ["!the quick brown fox ", " jump over the lazy dog"])
def test_4parts(self): self._data = "the quick brown\n fox jump over\n the lazy \ndog" client = TCPClientStream("127.0.0.1", 10000, eol="\n") res = [x for x in client.readline()] self.assertEqual( res, ["the quick brown", " fox jump over", " the lazy ", "dog"])
def test_data_start_with_garbage(self): self._data = "\u0394\nthe quick\nbrown fox" client = TCPClientStream("127.0.0.1", 10000, eol="\n") res = [x for x in client.readline()] self.assertEqual(res, ["\u0394", "the quick", "brown fox"])
def test_tcp_client_readline(self): self._data = "hello\nworld" client = TCPClientStream("127.0.0.1", 10000, eol="\n") res = [x for x in client.readline()] self.assertEqual(res, ["hello", "world"])