diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-09-24 11:10:21 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-09-24 11:10:21 +1200 |
commit | 3a21e28bf13b5710639337fdc29741e9b6b71405 (patch) | |
tree | 6a140bc2a0d5b331ca6ee73986375bae7c263e20 /test/test_tcp.py | |
parent | 8a6cca530c5293aa2b77edd3bf928540ec771928 (diff) | |
download | mitmproxy-3a21e28bf13b5710639337fdc29741e9b6b71405.tar.gz mitmproxy-3a21e28bf13b5710639337fdc29741e9b6b71405.tar.bz2 mitmproxy-3a21e28bf13b5710639337fdc29741e9b6b71405.zip |
Split FileLike into Writer and Reader, and add logging functionality.
Diffstat (limited to 'test/test_tcp.py')
-rw-r--r-- | test/test_tcp.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/test/test_tcp.py b/test/test_tcp.py index 67c56a37..9d581939 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -228,8 +228,8 @@ class TestTCPClient: class TestFileLike: def test_wrap(self): s = cStringIO.StringIO("foobar\nfoobar") - s = tcp.FileLike(s) s.flush() + s = tcp.Reader(s) assert s.readline() == "foobar\n" assert s.readline() == "foobar" # Test __getattr__ @@ -237,11 +237,39 @@ class TestFileLike: def test_limit(self): s = cStringIO.StringIO("foobar\nfoobar") - s = tcp.FileLike(s) + s = tcp.Reader(s) assert s.readline(3) == "foo" def test_limitless(self): s = cStringIO.StringIO("f"*(50*1024)) - s = tcp.FileLike(s) + s = tcp.Reader(s) ret = s.read(-1) assert len(ret) == 50 * 1024 + + def test_readlog(self): + s = cStringIO.StringIO("foobar\nfoobar") + s = tcp.Reader(s) + assert not s.is_logging() + s.start_log() + assert s.is_logging() + s.readline() + assert s.get_log() == "foobar\n" + s.read(1) + assert s.get_log() == "foobar\nf" + s.start_log() + assert s.get_log() == "" + s.read(1) + assert s.get_log() == "o" + s.stop_log() + tutils.raises(ValueError, s.get_log) + + def test_writelog(self): + s = cStringIO.StringIO() + s = tcp.Writer(s) + s.start_log() + assert s.is_logging() + s.write("x") + assert s.get_log() == "x" + s.write("x") + assert s.get_log() == "xx" + |