diff --git a/python-pscheduler/pscheduler/tests/interface_test.py b/python-pscheduler/pscheduler/tests/interface_test.py index 7377c3e1d..c2d19368d 100644 --- a/python-pscheduler/pscheduler/tests/interface_test.py +++ b/python-pscheduler/pscheduler/tests/interface_test.py @@ -4,6 +4,7 @@ """ import unittest +import socket from base_test import PschedTestBase @@ -15,6 +16,8 @@ class TestInterface(PschedTestBase): Interface tests. """ + ip_to_test = socket.gethostbyname('localhost') + # The following are wrappers around another library and don't need # testing: # source_interface @@ -24,13 +27,12 @@ def test_local_ip(self): """Local ip test""" localips = LocalIPList(refresh=5) - self.assertTrue('localhost' in localips) + self.assertTrue(self.ip_to_test in localips) def test_source_interface(self): """Source interface test""" - ip = 'localhost' - address, interface = source_interface(ip) - self.assertEqual(address, ip) + address, interface = source_interface(self.ip_to_test) + self.assertEqual(address, self.ip_to_test) self.assertNotEqual(interface, None) diff --git a/python-pscheduler/pscheduler/tests/limitprocessor_identifier_localif_test.py b/python-pscheduler/pscheduler/tests/limitprocessor_identifier_localif_test.py index 370813ae8..cbd92aef8 100644 --- a/python-pscheduler/pscheduler/tests/limitprocessor_identifier_localif_test.py +++ b/python-pscheduler/pscheduler/tests/limitprocessor_identifier_localif_test.py @@ -4,6 +4,7 @@ """ import unittest +import socket from base_test import PschedTestBase @@ -33,7 +34,7 @@ def test_identifier(self): ident = IdentifierLocalIF(DATA) self.assertEqual(ident.evaluate({ "requester": "192.168.1.1" }), False) - self.assertEqual(ident.evaluate({ "requester": "localhost" }), True) + self.assertEqual(ident.evaluate({ "requester": socket.gethostbyname("localhost") }), True)