diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-20 20:14:35 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-20 20:14:35 +1200 |
commit | 21ef35fd281a3f0783b08276db8407b12f33ae5d (patch) | |
tree | 53b088e606aa0f190e5898521a207cb13404ffef /test/test_rparse.py | |
parent | 3d9e8b2dbf7057fdcc72c74e1ffa265631750c98 (diff) | |
download | mitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.tar.gz mitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.tar.bz2 mitmproxy-21ef35fd281a3f0783b08276db8407b12f33ae5d.zip |
Much simpler rewrite of inner data sending loop.
We don't have to do the asynchronous code contortion anymore.
Diffstat (limited to 'test/test_rparse.py')
-rw-r--r-- | test/test_rparse.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/test_rparse.py b/test/test_rparse.py index cb1076c2..f4b408b2 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -250,6 +250,18 @@ class TestParseResponse: class TestWriteValues: + def test_send_chunk(self): + v = "foobarfoobar" + for bs in range(1, len(v)+2): + s = cStringIO.StringIO() + rparse.send_chunk(s, v, bs, 0, len(v)) + assert s.getvalue() == v + for start in range(len(v)): + for end in range(len(v)): + s = cStringIO.StringIO() + rparse.send_chunk(s, v, bs, start, end) + assert s.getvalue() == v[start:end] + def test_write_values_disconnects(self): s = cStringIO.StringIO() tst = "foo"*100 @@ -257,11 +269,17 @@ class TestWriteValues: assert not s.getvalue() def test_write_values(self): - tst = "foo"*1025 + tst = "foobarvoing" s = cStringIO.StringIO() rparse.write_values(s, [tst], []) assert s.getvalue() == tst + for bs in range(1, len(tst) + 2): + for off in range(len(tst)): + s = cStringIO.StringIO() + rparse.write_values(s, [tst], [(off, "disconnect")], blocksize=bs) + assert s.getvalue() == tst[:off] + def test_write_values_pauses(self): tst = "".join(str(i) for i in range(10)) for i in range(2, 10): |