From: Ben Darnell Date: Mon, 17 Feb 2014 04:41:15 +0000 (-0500) Subject: Add a py26-trollius test case and fix a bug with timedelta on 2.6. X-Git-Tag: v4.0.0b1~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2cae31d18abdce05631580f3c2853e959f7818f;p=thirdparty%2Ftornado.git Add a py26-trollius test case and fix a bug with timedelta on 2.6. --- diff --git a/tornado/platform/asyncio.py b/tornado/platform/asyncio.py index 0a3fba3f7..3f86cc7d1 100644 --- a/tornado/platform/asyncio.py +++ b/tornado/platform/asyncio.py @@ -14,7 +14,8 @@ import asyncio import datetime import functools -from tornado.ioloop import IOLoop +# _Timeout is used for its timedelta_to_seconds method for py26 compatibility. +from tornado.ioloop import IOLoop, _Timeout from tornado import stack_context @@ -108,7 +109,7 @@ class BaseAsyncIOLoop(IOLoop): if isinstance(deadline, (int, float)): delay = max(deadline - self.time(), 0) elif isinstance(deadline, datetime.timedelta): - delay = deadline.total_seconds() + delay = _Timeout.timedelta_to_seconds(deadline) else: raise TypeError("Unsupported deadline %r", deadline) return self.asyncio_loop.call_later(delay, self._run_callback, diff --git a/tox.ini b/tox.ini index 92fbcabdd..a82bbc4e5 100644 --- a/tox.ini +++ b/tox.ini @@ -28,7 +28,7 @@ envlist = # Alternate IOLoops. py2-select, py3-select, py2-twisted, py26-twisted, py2-twistedlayered, - py33-asyncio, py2-trollius, + py33-asyncio, py26-trollius, py2-trollius, # Other configurations; see comments below. py2-monotonic, py3-monotonic, @@ -164,7 +164,7 @@ deps = asyncio commands = python -m tornado.test.runtests --ioloop=tornado.platform.asyncio.AsyncIOLoop {posargs:} -# Trollius is the py2.7 backport of asyncio. +# Trollius is the py2 backport of asyncio. [testenv:py2-trollius] basepython = python2.7 # Pycurl tests currently fail with trollius. @@ -173,6 +173,14 @@ deps = trollius>=0.1.1 commands = python -m tornado.test.runtests --ioloop=tornado.platform.asyncio.AsyncIOLoop {posargs:} +[testenv:py26-trollius] +basepython = python2.6 +# Pycurl tests currently fail with trollius. +deps = + {[testenv:py26-full]deps} + trollius>=0.1.3 +commands = python -m tornado.test.runtests --ioloop=tornado.platform.asyncio.AsyncIOLoop {posargs:} + [testenv:py2-monotonic] basepython = python2.7 deps =