summaryrefslogtreecommitdiff
path: root/tests/test_adjustments.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_adjustments.py')
-rw-r--r--tests/test_adjustments.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/test_adjustments.py b/tests/test_adjustments.py
index 303c1aa..420ee4c 100644
--- a/tests/test_adjustments.py
+++ b/tests/test_adjustments.py
@@ -1,16 +1,9 @@
-import sys
import socket
+import sys
+import unittest
import warnings
-from waitress.compat import (
- PY2,
- WIN,
-)
-
-if sys.version_info[:2] == (2, 6): # pragma: no cover
- import unittest2 as unittest
-else: # pragma: no cover
- import unittest
+from waitress.compat import WIN
class Test_asbool(unittest.TestCase):
@@ -60,10 +53,12 @@ class Test_as_socket_list(unittest.TestCase):
socket.socket(socket.AF_INET, socket.SOCK_STREAM),
socket.socket(socket.AF_INET6, socket.SOCK_STREAM),
]
+
if hasattr(socket, "AF_UNIX"):
sockets.append(socket.socket(socket.AF_UNIX, socket.SOCK_STREAM))
new_sockets = as_socket_list(sockets)
self.assertEqual(sockets, new_sockets)
+
for sock in sockets:
sock.close()
@@ -77,6 +72,7 @@ class Test_as_socket_list(unittest.TestCase):
]
new_sockets = as_socket_list(sockets)
self.assertEqual(new_sockets, [sockets[0], sockets[1]])
+
for sock in [sock for sock in sockets if isinstance(sock, socket.socket)]:
sock.close()
@@ -99,6 +95,7 @@ class TestAdjustments(unittest.TestCase):
return True
except socket.gaierror as e:
# Check to see what the error is
+
if e.errno == socket.EAI_ADDRFAMILY:
return False
else:
@@ -220,11 +217,12 @@ class TestAdjustments(unittest.TestCase):
self.assertRaises(ValueError, self._makeOne, listen="127.0.0.1:test")
def test_service_port(self):
- if WIN and PY2: # pragma: no cover
- # On Windows and Python 2 this is broken, so we raise a ValueError
+ if WIN: # pragma: no cover
+ # On Windows this is broken, so we raise a ValueError
self.assertRaises(
ValueError, self._makeOne, listen="127.0.0.1:http",
)
+
return
inst = self._makeOne(listen="127.0.0.1:http 0.0.0.0:https")
@@ -406,6 +404,9 @@ class TestCLI(unittest.TestCase):
return Adjustments.parse_args(argv)
+ def assertDictContainsSubset(self, subset, dictionary):
+ self.assertTrue(set(subset.items()) <= set(dictionary.items()))
+
def test_noargs(self):
opts, args = self.parse([])
self.assertDictEqual(opts, {"call": False, "help": False})