Skip to content

Commit 49d1fc8

Browse files
committed
debug git actions
1 parent 7fb1d21 commit 49d1fc8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/test_ssh_path.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
from ssh_utilities import Connection
2020
import getpass
21+
import socket
2122

2223
logging.basicConfig(stream=sys.stderr)
2324
log = logging.getLogger(__name__)
@@ -34,6 +35,18 @@ class TestSSHPath(TestCase):
3435

3536
def setUp(self):
3637

38+
def get_ip():
39+
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
40+
try:
41+
# doesn't even have to be reachable
42+
s.connect(('10.255.255.255', 1))
43+
IP = s.getsockname()[0]
44+
except Exception:
45+
IP = '127.0.0.1'
46+
finally:
47+
s.close()
48+
return IP
49+
3750
self.user = os.environ.get("USER", "rynik")
3851
self.home = os.environ.get("HOME", Path.home())
3952
self.os = os.name
@@ -46,14 +59,15 @@ def setUp(self):
4659
#else:
4760
# c = Connection.open(self.user, "127.0.0.1", ssh_key_file=None,
4861
# ssh_password="12345678", server_name="test")
62+
localhost = get_ip()
4963
user = getpass.getuser()
5064
Connection.add_hosts({
5165
"user": user,
52-
"hostname": "localhost",
66+
"hostname": localhost,
5367
"identityfile": "~/.ssh/id_rsa"
5468
})
5569
print(Connection.available_hosts)
56-
c = Connection.get("localhost", local=False)
70+
c = Connection.get(localhost, local=False)
5771

5872
self.p = c.pathlib.Path("/tmp")
5973

0 commit comments

Comments
 (0)