diff options
author | vieira <vieira@yubo.be> | 2017-11-06 23:00:06 +0000 |
---|---|---|
committer | Brian May <brian@linuxpenguins.xyz> | 2017-11-07 10:08:16 +1100 |
commit | 416636fa9b41e55d63a358fc997ad80174222a46 (patch) | |
tree | 08e6a66723326a62d8987708c4751815c4c5ecbf | |
parent | 4300a02343b1b9aa47b6e1576fcc6675e806f9fb (diff) |
Mock socket bind to avoid depending on local IPs being available in test box
-rw-r--r-- | sshuttle/tests/client/test_helpers.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sshuttle/tests/client/test_helpers.py b/sshuttle/tests/client/test_helpers.py index 67c6682..4c7c9d6 100644 --- a/sshuttle/tests/client/test_helpers.py +++ b/sshuttle/tests/client/test_helpers.py @@ -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) |