]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Test that tornado.database is at least importable on all supported pythons.
authorBen Darnell <ben@bendarnell.com>
Wed, 3 Aug 2011 06:26:50 +0000 (23:26 -0700)
committerBen Darnell <ben@bendarnell.com>
Wed, 3 Aug 2011 06:26:50 +0000 (23:26 -0700)
Fix a problem preventing import on pypy (but apparently there are still other
issues with running MySQLdb on pypy, so the module will not actually work yet).

tornado/database.py
tornado/test/import_test.py
tox.ini

index e0f16e706b57a505891aec9425dd99d0bcb4810a..4a437fbf708383d8dd1f65d9176620daab00f0b5 100644 (file)
@@ -180,14 +180,14 @@ class Row(dict):
 # Fix the access conversions to properly recognize unicode/binary
 FIELD_TYPE = MySQLdb.constants.FIELD_TYPE
 FLAG = MySQLdb.constants.FLAG
-CONVERSIONS = copy.deepcopy(MySQLdb.converters.conversions)
+CONVERSIONS = copy.copy(MySQLdb.converters.conversions)
 
 field_types = [FIELD_TYPE.BLOB, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING]
 if 'VARCHAR' in vars(FIELD_TYPE):
     field_types.append(FIELD_TYPE.VARCHAR)
 
 for field_type in field_types:
-    CONVERSIONS[field_type].insert(0, (FLAG.BINARY, str))
+    CONVERSIONS[field_type] = [(FLAG.BINARY, str)] + CONVERSIONS[field_type]
 
 
 # Alias some common MySQL exceptions
index b146eb90e7f413408bc0802d732dba1984d48ac0..7da1a1ef91b4e85bf8b4fc6fbb959803b2f3ff88 100644 (file)
@@ -28,3 +28,30 @@ class ImportTest(unittest.TestCase):
         import tornado.web
         import tornado.websocket
         import tornado.wsgi
+
+    # for modules with dependencies, if those dependencies can be loaded,
+    # load them too.
+
+    def test_import_pycurl(self):
+        try:
+            import pycurl
+        except ImportError:
+            pass
+        else:
+            import tornado.curl_httpclient
+
+    def test_import_mysqldb(self):
+        try:
+            import MySQLdb
+        except ImportError:
+            pass
+        else:
+            import tornado.database
+
+    def test_import_twisted(self):
+        try:
+            import twisted
+        except ImportError:
+            pass
+        else:
+            import tornado.platform.twisted
diff --git a/tox.ini b/tox.ini
index 4816171f58e41939123a6143351306becae6e862..cdcce34525157ee032e4772369338e848473d6e3 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -5,10 +5,15 @@
 #
 # See also tornado/test/run_pyversion_tests.py, which is faster but
 # less thorough.
+#
+# On my macports-based setup, the environment variable
+# ARCHFLAGS='-arch x86_64' must be set when building pycurl, and a
+# symlink from mysql_config to mysql_config5 must exist when building
+# MySQL-python.
 [tox]
 # "-full" variants include optional dependencies, to ensure
 # that things work both in a bare install and with all the extras.
-envlist = py25, py25-full, py26, py26-full, py27, py27-full, pypy, py32
+envlist = py25, py25-full, py26, py26-full, py27, py27-full, pypy, pypy-full, py32
 [testenv]
 commands = python -m tornado.test.runtests {posargs:}
 
@@ -26,10 +31,8 @@ deps = simplejson
 
 [testenv:py25-full]
 basepython = python2.5
-# pycurl doesn't install cleanly for me from pip on 2.5, so get it from
-# the system python.
-sitepackages = True
 deps =
+     MySQL-python
      pycurl
      simplejson
      twisted
@@ -37,14 +40,22 @@ deps =
 [testenv:py26-full]
 basepython = python2.6
 deps =
+     MySQL-python
      pycurl
      twisted
 
 [testenv:py27-full]
 basepython = python2.7
 deps =
+     MySQL-python
      pycurl
      twisted
 
-# No pypy-full yet:  pycurl doesn't build, and installing twisted
-# under pypy takes a *very* long time.  Neither package works on python3.
+[testenv:pypy-full]
+# pycurl doesn't build with pypy, and installing twisted under pypy takes
+# a *very* long time
+basepython = pypy
+deps =
+     MySQL-python
+
+# No py32-full yet: none of our dependencies currently work on python3.