From 7c83a709ea06f3b538f446860f3c7ed463a29b1f Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 1 Feb 2016 19:24:30 +0100 Subject: [PATCH] add test for Reader.peek() --- test/test_tcp.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_tcp.py b/test/test_tcp.py index 738fb2eb2..a68bf1e6e 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -713,6 +713,20 @@ class TestFileLike: tutils.raises(TcpReadIncomplete, s.safe_read, 10) +class TestPeek(tservers.ServerTestBase): + handler = EchoHandler + + def test_peek(self): + testval = b"peek!\n" + c = tcp.TCPClient(("127.0.0.1", self.port)) + c.connect() + c.wfile.write(testval) + c.wfile.flush() + + assert c.rfile.peek(4) == "peek"[:4] + assert c.rfile.peek(6) == testval + + class TestAddress: def test_simple(self):