diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-02-27 22:02:52 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-02-27 22:02:52 +0100 |
commit | da1eb94ccd36b31ea7e05c6a4e01dd5a6cf20376 (patch) | |
tree | 3e5d2b4b652c0fc80f70a73c34dc8bd75cd63ccd /test/test_socks.py | |
parent | 63fb43369029d33ce77cb2ce1df397e99494562c (diff) | |
download | mitmproxy-da1eb94ccd36b31ea7e05c6a4e01dd5a6cf20376.tar.gz mitmproxy-da1eb94ccd36b31ea7e05c6a4e01dd5a6cf20376.tar.bz2 mitmproxy-da1eb94ccd36b31ea7e05c6a4e01dd5a6cf20376.zip |
100% test coverage :tada:
Diffstat (limited to 'test/test_socks.py')
-rw-r--r-- | test/test_socks.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/test_socks.py b/test/test_socks.py index 740fdb9c..aa4f9c11 100644 --- a/test/test_socks.py +++ b/test/test_socks.py @@ -1,5 +1,6 @@ from cStringIO import StringIO import socket +import mock from nose.plugins.skip import SkipTest from netlib import socks, tcp import tutils @@ -81,4 +82,15 @@ def test_message_unknown_atyp(): tutils.raises(socks.SocksError, socks.Message.from_file, raw) m = socks.Message(5, 1, 0x02, tcp.Address(("example.com", 5050))) - tutils.raises(socks.SocksError, m.to_file, StringIO())
\ No newline at end of file + tutils.raises(socks.SocksError, m.to_file, StringIO()) + +def test_read(): + cs = StringIO("1234") + assert socks._read(cs, 3) == "123" + + cs = StringIO("123") + tutils.raises(socks.SocksError, socks._read, cs, 4) + + cs = mock.Mock() + cs.read = mock.Mock(side_effect=socket.error) + tutils.raises(socks.SocksError, socks._read, cs, 4)
\ No newline at end of file |