Permalink
Browse files

Add timeout to restmail exception message.

  • Loading branch information...
1 parent 09b9041 commit 0ad877c7563d6afdd2f1de22668a61db654e1383 @davehunt committed Jul 25, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 tests/restmail.py
View
@@ -11,6 +11,7 @@
def get_mail(username, message_count=1, timeout=60):
+ username = username.partition('@restmail.net')[0]
end_time = time.time() + timeout
while(True):
response = requests.get(
@@ -22,9 +23,10 @@ def get_mail(username, message_count=1, timeout=60):
time.sleep(0.5)
if(time.time() > end_time):
break
- raise Exception('Timeout getting restmail for %(USERNAME)s. '
- 'Expected %(EXPECTED_MESSAGE_COUNT)s messages '
- 'but there were %(ACTUAL_MESSAGE_COUNT)s.' % {
+ raise Exception('Timeout after %(TIMEOUT)s seconds getting restmail for '
+ '%(USERNAME)s. Expected %(EXPECTED_MESSAGE_COUNT)s '
+ 'messages but there were %(ACTUAL_MESSAGE_COUNT)s.' % {
+ 'TIMEOUT': timeout,
'USERNAME': username,
'EXPECTED_MESSAGE_COUNT': message_count,
'ACTUAL_MESSAGE_COUNT': len(restmail)})

0 comments on commit 0ad877c

Please sign in to comment.