summaryrefslogtreecommitdiff
path: root/src/mailman/testing/helpers.py
diff options
context:
space:
mode:
authorBarry Warsaw2011-05-03 11:17:23 -0400
committerBarry Warsaw2011-05-03 11:17:23 -0400
commitf2f5f4dd0b3d3d6da1de66667f65272851d9cb3a (patch)
tree85c031e6a56e21ead0a66d827fd86679e3a659b2 /src/mailman/testing/helpers.py
parent2f683e5904daa97c98a8c6081dc93ef8bc8f3133 (diff)
downloadmailman-f2f5f4dd0b3d3d6da1de66667f65272851d9cb3a.tar.gz
mailman-f2f5f4dd0b3d3d6da1de66667f65272851d9cb3a.tar.zst
mailman-f2f5f4dd0b3d3d6da1de66667f65272851d9cb3a.zip
Diffstat (limited to 'src/mailman/testing/helpers.py')
-rw-r--r--src/mailman/testing/helpers.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py
index 74e00b501..71cddd0f4 100644
--- a/src/mailman/testing/helpers.py
+++ b/src/mailman/testing/helpers.py
@@ -47,6 +47,7 @@ from base64 import b64encode
from contextlib import contextmanager
from email import message_from_string
from httplib2 import Http
+from lazr.config import as_timedelta
from urllib import urlencode
from urllib2 import HTTPError
from zope import event
@@ -61,9 +62,6 @@ from mailman.interfaces.usermanager import IUserManager
from mailman.utilities.mailbox import Mailbox
-STARTUP_WAIT = datetime.timedelta(seconds=5)
-
-
def make_testable_runner(runner_class, name=None):
"""Create a queue runner that runs until its queue is empty.
@@ -221,16 +219,16 @@ def get_lmtp_client():
# It's possible the process has started but is not yet accepting
# connections. Wait a little while.
lmtp = LMTP()
- until = datetime.datetime.now() + STARTUP_WAIT
+ until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
while datetime.datetime.now() < until:
try:
response = lmtp.connect(
config.mta.lmtp_host, int(config.mta.lmtp_port))
print response
return lmtp
- except socket.error, error:
+ except socket.error as error:
if error[0] == errno.ECONNREFUSED:
- time.sleep(0.5)
+ time.sleep(0.1)
else:
raise
else:
@@ -240,15 +238,20 @@ def get_lmtp_client():
def wait_for_webservice():
"""Wait for the REST server to start serving requests."""
- # Time out after approximately 3 seconds.
- for count in range(30):
+ until = datetime.datetime.now() + as_timedelta(config.devmode.wait)
+ while datetime.datetime.now() < until:
try:
socket.socket().connect((config.webservice.hostname,
- int(config.webservice.port)))
- except socket.error:
- time.sleep(0.1)
+ int(config.webservice.port)))
+ except socket.error as error:
+ if error[0] == errno.ECONNREFUSED:
+ time.sleep(0.1)
+ else:
+ raise
else:
break
+ else:
+ raise RuntimeError('Connection refused')
def call_api(url, data=None, method=None, username=None, password=None):