Tornado's test suite now requires unittest2 on py25 and py26.
tornado.testing will use unittest2 if available but does not require
it.
This means we can no longer run the test suite under app engine 2.5,
although it still works for app engine 2.7.
# These are currently excluded from the main tox.ini because their
# logs are spammy and they're a little flaky.
[tox]
-envlist = py25-appengine, py27-appengine
+envlist = py27-appengine
[testenv]
changedir = {toxworkdir}
+# py25-appengine was broken by the addition of unittest2. Need to figure
+# out a way to smuggle unittest2 into the appengine environment if we don't
+# drop py25 support.
[testenv:py25-appengine]
basepython = python2.5
commands = python {toxinidir}/py25/runtests.py {posargs:}
+deps = unittest2
[testenv:py27-appengine]
basepython = python2.7
from __future__ import absolute_import, division, with_statement
import tornado.escape
-import unittest
from tornado.escape import utf8, xhtml_escape, xhtml_unescape, url_escape, url_unescape, to_unicode, json_decode, json_encode
from tornado.util import b
+from tornado.test.util import unittest
linkify_tests = [
# (input, linkify_kwargs, expected_output)
from tornado.iostream import IOStream
from tornado.simple_httpclient import SimpleAsyncHTTPClient
from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, LogTrapTestCase
+from tornado.test.util import unittest
from tornado.util import b, bytes_type
from tornado.web import Application, RequestHandler
import os
import socket
import sys
import tempfile
-import unittest
try:
import ssl
from tornado.httputil import url_concat, parse_multipart_form_data, HTTPHeaders
from tornado.escape import utf8
from tornado.testing import LogTrapTestCase
+from tornado.test.util import unittest
from tornado.util import b
import logging
-import unittest
class TestUrlConcat(unittest.TestCase):
from __future__ import absolute_import, division, with_statement
-import unittest
+from tornado.test.util import unittest
class ImportTest(unittest.TestCase):
import datetime
import socket
import time
-import unittest
from tornado.ioloop import IOLoop
from tornado.netutil import bind_sockets
from tornado.testing import AsyncTestCase, LogTrapTestCase, get_unused_port
+from tornado.test.util import unittest
class TestIOLoop(AsyncTestCase, LogTrapTestCase):
import os
import tornado.locale
-import unittest
+from tornado.test.util import unittest
class TranslationLoaderTest(unittest.TestCase):
import os
import re
import tempfile
-import unittest
import warnings
from tornado.escape import utf8
from tornado.options import _Options, _LogFormatter
+from tornado.test.util import unittest
from tornado.util import b, bytes_type
from __future__ import absolute_import, division, with_statement
import sys
-import unittest
+from tornado.test.util import unittest
TEST_MODULES = [
'tornado.httputil.doctests',
from tornado.stack_context import StackContext, wrap
from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase
+from tornado.test.util import unittest
from tornado.util import b
from tornado.web import asynchronous, Application, RequestHandler
import contextlib
import functools
import logging
-import unittest
class TestRequestHandler(RequestHandler):
#!/usr/bin/env python
from __future__ import absolute_import, division, with_statement
-import unittest
import time
from tornado.testing import AsyncTestCase, LogTrapTestCase
+from tornado.test.util import unittest
class AsyncTestCaseTest(AsyncTestCase, LogTrapTestCase):
import tempfile
import thread
import threading
-import unittest
try:
import fcntl
from tornado.ioloop import IOLoop
from tornado.platform.auto import set_close_exec
from tornado.testing import get_unused_port
+from tornado.test.util import unittest
from tornado.util import import_object
from tornado.web import RequestHandler, Application
--- /dev/null
+from __future__ import absolute_import, division, with_statement
+
+import sys
+
+# Encapsulate the choice of unittest or unittest2 here.
+# To be used as 'from tornado.test.util import unittest'.
+if sys.version_info >= (2, 7):
+ import unittest
+else:
+ import unittest2 as unittest
from __future__ import absolute_import, division, with_statement
import sys
-import unittest
from tornado.util import raise_exc_info
+from tornado.test.util import unittest
class RaiseExcInfoTest(unittest.TestCase):
raise_exc_info(exc_info)
self.fail("didn't get expected exception")
except TwoArgException, e:
- self.assertTrue(e is exc_info[1])
+ self.assertIs(e, exc_info[1])
import signal
import sys
import time
-import unittest
+
+# Tornado's own test suite requires the updated unittest module
+# (either py27+ or unittest2) so tornado.test.util enforces
+# this requirement, but for other users of tornado.testing we want
+# to allow the older version if unitest2 is not available.
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
_next_port = 10000
[testenv:py25]
basepython = python2.5
-deps = simplejson
+deps =
+ simplejson
+ unittest2
[testenv:py25-full]
basepython = python2.5
simplejson
# twisted is dropping python 2.5 support in 12.2.0
twisted<=12.1.0
+ unittest2
# zope.interface (used by twisted) dropped python 2.5 support in 4.0
zope.interface<4.0
+[testenv:py26]
+basepython = python2.6
+deps = unittest2
+
# py26-full deliberately runs an older version of twisted to ensure
# we're still compatible with the oldest version we support.
[testenv:py26-full]
MySQL-python
pycurl
twisted==11.0.0
+ unittest2
[testenv:py27-full]
basepython = python2.7