Group :: Development/Python3
RPM: python3-module-waitress
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: python3-module-waitress-2.0.0-alt.patch
Download
Download
setup.cfg | 2 +-
tests/fixtureapps/getline.py | 2 +-
tests/test_adjustments.py | 33 +++++++++++++++++++++++++--------
tests/test_functional.py | 6 ++----
4 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 245b7f4..4306dd4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -65,4 +65,4 @@ python_files = test_*.py
python_classes = Test_*
testpaths =
tests
-addopts = --cov -W always
+addopts = -W always
diff --git a/tests/fixtureapps/getline.py b/tests/fixtureapps/getline.py
index bb5b39c..9f299ae 100644
--- a/tests/fixtureapps/getline.py
+++ b/tests/fixtureapps/getline.py
@@ -9,7 +9,7 @@ if __name__ == "__main__":
url = sys.argv[1]
headers = {"Content-Type": "text/plain; charset=utf-8"}
try:
- resp = urlopen(url)
+ resp = urlopen(url, timeout=15)
line = resp.readline().decode("ascii") # py3
except URLError:
line = "failed to read %s" % url
diff --git a/tests/test_adjustments.py b/tests/test_adjustments.py
index 69cdf51..4c45794 100644
--- a/tests/test_adjustments.py
+++ b/tests/test_adjustments.py
@@ -2,6 +2,7 @@ import socket
import sys
import unittest
import warnings
+import errno
from waitress.compat import WIN
@@ -51,9 +52,12 @@ class Test_as_socket_list(unittest.TestCase):
sockets = [
socket.socket(socket.AF_INET, socket.SOCK_STREAM),
- socket.socket(socket.AF_INET6, socket.SOCK_STREAM),
]
-
+ try:
+ sockets.append(socket.socket(socket.AF_INET6, socket.SOCK_STREAM))
+ except socket.error as e:
+ if e.errno != errno.EAFNOSUPPORT:
+ raise e
if hasattr(socket, "AF_UNIX"):
sockets.append(socket.socket(socket.AF_UNIX, socket.SOCK_STREAM))
new_sockets = as_socket_list(sockets)
@@ -67,11 +71,20 @@ class Test_as_socket_list(unittest.TestCase):
sockets = [
socket.socket(socket.AF_INET, socket.SOCK_STREAM),
- socket.socket(socket.AF_INET6, socket.SOCK_STREAM),
{"something": "else"},
]
+ try:
+ sockets.insert(
+ 0, socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+ )
+ except socket.error as e:
+ if e.errno != errno.EAFNOSUPPORT:
+ raise e
new_sockets = as_socket_list(sockets)
- self.assertEqual(new_sockets, [sockets[0], sockets[1]])
+ self.assertEqual(
+ new_sockets,
+ [sock for sock in sockets if isinstance(sock, socket.socket)],
+ )
for sock in [sock for sock in sockets if isinstance(sock, socket.socket)]:
sock.close()
@@ -244,13 +257,17 @@ class TestAdjustments(unittest.TestCase):
def test_good_sockets(self):
sockets = [
- socket.socket(socket.AF_INET6, socket.SOCK_STREAM),
- socket.socket(socket.AF_INET, socket.SOCK_STREAM),
+ socket.socket(socket.AF_INET, socket.SOCK_STREAM)
]
+ try:
+ sockets.append(socket.socket(socket.AF_INET6, socket.SOCK_STREAM))
+ except socket.error as e:
+ if e.errno != errno.EAFNOSUPPORT:
+ raise e
inst = self._makeOne(sockets=sockets)
self.assertEqual(inst.sockets, sockets)
- sockets[0].close()
- sockets[1].close()
+ for sk in sockets:
+ sk.close()
def test_dont_mix_sockets_and_listen(self):
sockets = [socket.socket(socket.AF_INET, socket.SOCK_STREAM)]
diff --git a/tests/test_functional.py b/tests/test_functional.py
index 04a2df4..10e1588 100644
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -152,12 +152,10 @@ class SleepyThreadTests(TcpTests, unittest.TestCase):
for cmd in cmds:
procs.append(subprocess.Popen(cmd, stdout=w))
- time.sleep(3)
for proc in procs:
- if proc.returncode is not None: # pragma: no cover
- proc.terminate()
- proc.wait()
+ proc.communicate()
+
# the notsleepy response should always be first returned (it sleeps
# for 2 seconds, then returns; the notsleepy response should be
# processed in the meantime)