]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- 2.3 fixup part three: 100% on postgres, mysql
authorJason Kirtland <jek@discorporate.us>
Tue, 22 Jan 2008 21:08:21 +0000 (21:08 +0000)
committerJason Kirtland <jek@discorporate.us>
Tue, 22 Jan 2008 21:08:21 +0000 (21:08 +0000)
lib/sqlalchemy/databases/mysql.py
test/profiling/zoomark.py
test/testenv.py
test/testlib/__init__.py
test/testlib/compat.py
test/testlib/testing.py

index e7e3ec069f201b7d2f5d0c73d561dcc92fedb4e5..e01cec2ab77d6109f9753f580d872212b2b9ce5f 100644 (file)
@@ -2156,7 +2156,7 @@ class MySQLSchemaReflector(object):
         default = spec.get('default', None)
         if default is not None and default != 'NULL':
             # Defaults should be in the native charset for the moment
-            default = default.decode(charset)
+            default = default.encode(charset)
             if type_ == 'timestamp':
                 # can't be NULL for TIMESTAMPs
                 if (default[0], default[-1]) != ("'", "'"):
index 8c46f4188bb2d16d87c68ba63a11c910d687091e..d7ef0bf52479d2cbf250a2e81e9f2648f808dbdb 100644 (file)
@@ -8,7 +8,7 @@ import time
 import testenv; testenv.configure_for_tests()
 from testlib import testing, profiling
 from sqlalchemy import *
-
+from testlib import set
 
 ITERATIONS = 1
 
@@ -21,6 +21,7 @@ class ZooMarkTest(testing.AssertMixin):
     """
 
     __only_on__ = 'postgres'
+    __skip_if__ = ((lambda: sys.version_info < (2, 4)), )
 
     @profiling.profiled('create', call_range=(1500, 1880), always=True)
     def test_1_create_tables(self):
index bdfd6efc0ef4ca47c426b4b974c5d53327e76d36..35e9032aadeb03f7deba2222ea60ba6a76376a0b 100644 (file)
@@ -1,6 +1,10 @@
 """First import for all test cases, sets sys.path and loads configuration."""
 
-import sys, os, logging
+import sys, os, logging, warnings
+
+if sys.version_info < (2, 4):
+    warnings.filterwarnings('ignore', category=FutureWarning)
+
 from testlib.testing import main
 import testlib.config
 
@@ -28,3 +32,4 @@ def simple_setup():
 
         testlib.config.configure_defaults()
         _setup = True
+
index 46852191a26336df73892cd2c641d0a9873ee1f6..49ef0ca8a347fe9e88db9e16b8226480601b0a81 100644 (file)
@@ -11,7 +11,7 @@ from testlib.testing import rowset
 from testlib.testing import PersistTest, AssertMixin, ORMTest, SQLCompileTest
 import testlib.profiling as profiling
 import testlib.engines as engines
-from testlib.compat import set, sorted, _function_named
+from testlib.compat import set, frozenset, sorted, _function_named
 
 
 __all__ = ('testing',
@@ -20,4 +20,4 @@ __all__ = ('testing',
            'rowset',
            'PersistTest', 'AssertMixin', 'ORMTest', 'SQLCompileTest',
            'profiling', 'engines',
-           'set', 'sorted', '_function_named')
+           'set', 'frozenset', 'sorted', '_function_named')
index 8d2b35d4a2710e72beb84bf7be21685c8ccb4f2d..4f2006afdb90b21e70100b0ff9055d1c3e2d456e 100644 (file)
@@ -1,6 +1,6 @@
-import itertools, new
+import itertools, new, sys, warnings
 
-__all__ = 'set', 'sorted', '_function_named'
+__all__ = 'set', 'frozenset', 'sorted', '_function_named'
 
 try:
     set = set
@@ -51,6 +51,12 @@ except NameError:
                 return NotImplemented
             return sets.Set.__isub__(self, other)
 
+try:
+    frozenset = frozenset
+except NameError:
+    import sets
+    from sets import ImmutableSet as frozenset
+
 try:
     sorted = sorted
 except NameError:
@@ -69,3 +75,4 @@ def _function_named(fn, newname):
         fn = new.function(fn.func_code, fn.func_globals, newname,
                           fn.func_defaults, fn.func_closure)
     return fn
+
index 8b64ce7db2a293689af547b4f303ad558de31602..cb10cf61a0d7c36dbaedc12d3eb3c59440dd85a5 100644 (file)
@@ -271,10 +271,15 @@ def resetwarnings():
     global sa_exceptions
     if sa_exceptions is None:
         import sqlalchemy.exceptions as sa_exceptions
+
     warnings.resetwarnings()
     warnings.filterwarnings('error', category=sa_exceptions.SADeprecationWarning)
     warnings.filterwarnings('error', category=sa_exceptions.SAWarning)
 
+    if sys.version_info < (2, 4):
+        warnings.filterwarnings('ignore', category=FutureWarning)
+
+
 def against(*queries):
     """Boolean predicate, compares to testing database configuration.
 
@@ -418,6 +423,10 @@ class PersistTest(unittest.TestCase):
     # dialect.  If you need multiple, use __unsupported_on__ and invert.
     __only_on__ = None
 
+    # A sequence of no-arg callables. If any are True, the entire testcase is
+    # skipped.
+    __skip_if__ = None
+
     def __init__(self, *args, **params):
         unittest.TestCase.__init__(self, *args, **params)
 
@@ -431,6 +440,11 @@ class PersistTest(unittest.TestCase):
         """overridden to not return docstrings"""
         return None
 
+    if not hasattr(unittest.TestCase, 'assertTrue'):
+        assertTrue = unittest.TestCase.failUnless
+    if not hasattr(unittest.TestCase, 'assertFalse'):
+        assertFalse = unittest.TestCase.failIf
+
 class SQLCompileTest(PersistTest):
     def assert_compile(self, clause, result, params=None, checkparams=None, dialect=None):
         if dialect is None:
@@ -656,6 +670,12 @@ class TTestSuite(unittest.TestSuite):
                 print "'%s' unsupported on DB implementation '%s'" % (
                     init.__class__.__name__, config.db.name)
                 return True
+            if (getattr(init, '__skip_if__', False)):
+                for c in getattr(init, '__skip_if__'):
+                    if c():
+                        print "'%s' skipped by %s" % (
+                            init.__class__.__name__, c.__name__)
+                        return True
             for rule in getattr(init, '__excluded_on__', ()):
                 if _is_excluded(*rule):
                     print "'%s' unsupported on DB %s version %s" % (