[IMP] readability of phantomjs timeouts

bzr revid: xmo@openerp.com-20140310101554-6imrb3hnd95q1wgu
This commit is contained in:
Xavier Morel 2014-03-10 11:15:54 +01:00
parent d16bcfb981
commit b3de4ca481
1 changed files with 5 additions and 2 deletions

View File

@ -16,6 +16,8 @@ import unittest2
import urllib2 import urllib2
import xmlrpclib import xmlrpclib
from datetime import datetime, timedelta
import openerp import openerp
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -194,11 +196,12 @@ class HttpCase(TransactionCase):
Other lines are relayed to the test log. Other lines are relayed to the test log.
""" """
t0 = time.time() t0 = datetime.now()
td = timedelta(seconds=timeout)
buf = bytearray() buf = bytearray()
while True: while True:
# timeout # timeout
self.assertLess(time.time(), t0 + timeout, self.assertLess(datetime.now() - t0, td,
"PhantomJS tests should take less than %s seconds" % timeout) "PhantomJS tests should take less than %s seconds" % timeout)
# read a byte # read a byte