aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_socks.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_socks.py')
-rw-r--r--test/test_socks.py14
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