aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_tcp.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-10-09 16:25:15 +1300
committerAldo Cortesi <aldo@nullcube.com>2012-10-09 16:25:15 +1300
commit77869634e20ae5a2646d7455e499866e9cfafbab (patch)
tree17bdda510637aeeb29a1c6381fb89bbaf6b2408f /test/test_tcp.py
parent15679e010d99def2fb7efd1de5533099a12772ca (diff)
downloadmitmproxy-77869634e20ae5a2646d7455e499866e9cfafbab.tar.gz
mitmproxy-77869634e20ae5a2646d7455e499866e9cfafbab.tar.bz2
mitmproxy-77869634e20ae5a2646d7455e499866e9cfafbab.zip
Limit reads to block length.
Diffstat (limited to 'test/test_tcp.py')
-rw-r--r--test/test_tcp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_tcp.py b/test/test_tcp.py
index c833ce07..5a12da91 100644
--- a/test/test_tcp.py
+++ b/test/test_tcp.py
@@ -255,6 +255,17 @@ class TestTCPClient:
class TestFileLike:
+ def test_blocksize(self):
+ s = cStringIO.StringIO("1234567890abcdefghijklmnopqrstuvwxyz")
+ s = tcp.Reader(s)
+ s.BLOCKSIZE = 2
+ assert s.read(1) == "1"
+ assert s.read(2) == "23"
+ assert s.read(3) == "456"
+ assert s.read(4) == "7890"
+ d = s.read(-1)
+ assert d.startswith("abc") and d.endswith("xyz")
+
def test_wrap(self):
s = cStringIO.StringIO("foobar\nfoobar")
s.flush()