add test for Reader.peek()

This commit is contained in:
Maximilian Hils 2016-02-01 19:24:30 +01:00
parent d253ebc142
commit 7c83a709ea

View File

@ -713,6 +713,20 @@ class TestFileLike:
tutils.raises(TcpReadIncomplete, s.safe_read, 10) 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: class TestAddress:
def test_simple(self): def test_simple(self):