Start using new unittest features from py27/unittest2.
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.
This commit is contained in:
parent
73c1ddfe2b
commit
4e91f6720b
|
@ -5,14 +5,18 @@
|
|||
# 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
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
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)
|
||||
|
|
|
@ -10,6 +10,7 @@ from tornado.ioloop import IOLoop
|
|||
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
|
||||
|
@ -17,7 +18,6 @@ import shutil
|
|||
import socket
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import ssl
|
||||
|
|
|
@ -5,9 +5,9 @@ from __future__ import absolute_import, division, with_statement
|
|||
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):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from __future__ import absolute_import, division, with_statement
|
||||
import unittest
|
||||
from tornado.test.util import unittest
|
||||
|
||||
|
||||
class ImportTest(unittest.TestCase):
|
||||
|
|
|
@ -5,11 +5,11 @@ from __future__ import absolute_import, division, with_statement
|
|||
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):
|
||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import absolute_import, division, with_statement
|
|||
|
||||
import os
|
||||
import tornado.locale
|
||||
import unittest
|
||||
from tornado.test.util import unittest
|
||||
|
||||
|
||||
class TranslationLoaderTest(unittest.TestCase):
|
||||
|
|
|
@ -4,11 +4,11 @@ import logging
|
|||
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
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from __future__ import absolute_import, division, with_statement
|
||||
import sys
|
||||
import unittest
|
||||
from tornado.test.util import unittest
|
||||
|
||||
TEST_MODULES = [
|
||||
'tornado.httputil.doctests',
|
||||
|
|
|
@ -3,12 +3,12 @@ from __future__ import absolute_import, division, with_statement
|
|||
|
||||
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):
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/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):
|
||||
|
|
|
@ -25,7 +25,6 @@ import signal
|
|||
import tempfile
|
||||
import thread
|
||||
import threading
|
||||
import unittest
|
||||
|
||||
try:
|
||||
import fcntl
|
||||
|
@ -46,6 +45,7 @@ from tornado.httpclient import AsyncHTTPClient
|
|||
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
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
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
|
|
@ -1,8 +1,8 @@
|
|||
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):
|
||||
|
@ -23,4 +23,4 @@ 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])
|
||||
|
|
|
@ -41,7 +41,15 @@ import os
|
|||
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
|
||||
|
||||
|
|
10
tox.ini
10
tox.ini
|
@ -28,7 +28,9 @@ changedir = {toxworkdir}
|
|||
|
||||
[testenv:py25]
|
||||
basepython = python2.5
|
||||
deps = simplejson
|
||||
deps =
|
||||
simplejson
|
||||
unittest2
|
||||
|
||||
[testenv:py25-full]
|
||||
basepython = python2.5
|
||||
|
@ -38,9 +40,14 @@ deps =
|
|||
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]
|
||||
|
@ -49,6 +56,7 @@ deps =
|
|||
MySQL-python
|
||||
pycurl
|
||||
twisted==11.0.0
|
||||
unittest2
|
||||
|
||||
[testenv:py27-full]
|
||||
basepython = python2.7
|
||||
|
|
Loading…
Reference in New Issue