summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-04-23 05:20:12 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-04-23 05:20:12 +0200
commitfc66da427cb176355d9d7a2d34796ecdff5dc870 (patch)
treefa2212d9bfba676b9db2e71432e1aec92b81d28f
parent027ec99c1291e0edeccbf5953e8c332cc0b320d6 (diff)
downloadpsutil-fc66da427cb176355d9d7a2d34796ecdff5dc870.tar.gz
assume AF_INET6 is always available
-rw-r--r--psutil/tests/__init__.py2
-rwxr-xr-xpsutil/tests/test_misc.py7
-rwxr-xr-xpsutil/tests/test_process.py2
-rwxr-xr-xpsutil/tests/test_system.py5
4 files changed, 7 insertions, 9 deletions
diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py
index d08aef01..05d2de2e 100644
--- a/psutil/tests/__init__.py
+++ b/psutil/tests/__init__.py
@@ -27,6 +27,7 @@ import threading
import time
import warnings
from socket import AF_INET
+from socket import AF_INET6
from socket import SOCK_DGRAM
from socket import SOCK_STREAM
@@ -131,7 +132,6 @@ SCRIPTS_DIR = os.path.join(ROOT_DIR, 'scripts')
# --- misc
-AF_INET6 = getattr(socket, "AF_INET6")
AF_UNIX = getattr(socket, "AF_UNIX", None)
PYTHON = os.path.realpath(sys.executable)
DEVNULL = open(os.devnull, 'r+')
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index 7abb28e8..5b34a343 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -282,10 +282,9 @@ class TestMisc(unittest.TestCase):
assert not supports_ipv6()
assert s.called
else:
- if hasattr(socket, 'AF_INET6'):
- with self.assertRaises(Exception):
- sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
- sock.bind(("::1", 0))
+ with self.assertRaises(Exception):
+ sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+ sock.bind(("::1", 0))
def test_isfile_strict(self):
from psutil._common import isfile_strict
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index 053f30ec..8b8006da 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -23,6 +23,7 @@ import time
import traceback
import types
from socket import AF_INET
+from socket import AF_INET6
from socket import SOCK_DGRAM
from socket import SOCK_STREAM
@@ -42,7 +43,6 @@ from psutil._compat import callable
from psutil._compat import long
from psutil._compat import PY3
from psutil._compat import unicode
-from psutil.tests import AF_INET6
from psutil.tests import AF_UNIX
from psutil.tests import APPVEYOR
from psutil.tests import call_until
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index b3018da7..79e217d4 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -30,7 +30,6 @@ from psutil import SUNOS
from psutil import WINDOWS
from psutil._compat import long
from psutil._compat import unicode
-from psutil.tests import AF_INET6
from psutil.tests import APPVEYOR
from psutil.tests import check_net_address
from psutil.tests import DEVNULL
@@ -559,7 +558,7 @@ class TestSystemAPIs(unittest.TestCase):
# self.assertEqual(sorted(nics.keys()),
# sorted(psutil.net_io_counters(pernic=True).keys()))
- families = set([socket.AF_INET, AF_INET6, psutil.AF_LINK])
+ families = set([socket.AF_INET, socket.AF_INET6, psutil.AF_LINK])
for nic, addrs in nics.items():
self.assertIsInstance(nic, (str, unicode))
self.assertEqual(len(set(addrs)), len(addrs))
@@ -592,7 +591,7 @@ class TestSystemAPIs(unittest.TestCase):
# TODO: skip AF_INET6 for now because I get:
# AddressValueError: Only hex digits permitted in
# u'c6f3%lxcbr0' in u'fe80::c8e0:fff:fe54:c6f3%lxcbr0'
- if addr.family != AF_INET6:
+ if addr.family != socket.AF_INET6:
check_net_address(ip, addr.family)
# broadcast and ptp addresses are mutually exclusive
if addr.broadcast: