Commit 416636fa authored by vieira's avatar vieira Committed by Brian May

Mock socket bind to avoid depending on local IPs being available in test box

parent 4300a023
......@@ -2,6 +2,7 @@ from mock import patch, call
import sys
import io
import socket
import errno
import sshuttle.helpers
......@@ -162,7 +163,11 @@ nameserver 2404:6800:4004:80c::4
]
def test_islocal():
@patch('sshuttle.helpers.socket.socket.bind')
def test_islocal(mock_bind):
bind_error = socket.error(errno.EADDRNOTAVAIL)
mock_bind.side_effect = [None, bind_error, None, bind_error]
assert sshuttle.helpers.islocal("127.0.0.1", socket.AF_INET)
assert not sshuttle.helpers.islocal("192.0.2.1", socket.AF_INET)
assert sshuttle.helpers.islocal("::1", socket.AF_INET6)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment