From: Jason Kirtland Date: Tue, 22 Jan 2008 21:08:21 +0000 (+0000) Subject: - 2.3 fixup part three: 100% on postgres, mysql X-Git-Tag: rel_0_4_3~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3cc2f7e0c308354f3f939c47c382a2d11845d4f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 2.3 fixup part three: 100% on postgres, mysql --- diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index e7e3ec069f..e01cec2ab7 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -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]) != ("'", "'"): diff --git a/test/profiling/zoomark.py b/test/profiling/zoomark.py index 8c46f4188b..d7ef0bf524 100644 --- a/test/profiling/zoomark.py +++ b/test/profiling/zoomark.py @@ -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): diff --git a/test/testenv.py b/test/testenv.py index bdfd6efc0e..35e9032aad 100644 --- a/test/testenv.py +++ b/test/testenv.py @@ -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 + diff --git a/test/testlib/__init__.py b/test/testlib/__init__.py index 46852191a2..49ef0ca8a3 100644 --- a/test/testlib/__init__.py +++ b/test/testlib/__init__.py @@ -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') diff --git a/test/testlib/compat.py b/test/testlib/compat.py index 8d2b35d4a2..4f2006afdb 100644 --- a/test/testlib/compat.py +++ b/test/testlib/compat.py @@ -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 + diff --git a/test/testlib/testing.py b/test/testlib/testing.py index 8b64ce7db2..cb10cf61a0 100644 --- a/test/testlib/testing.py +++ b/test/testlib/testing.py @@ -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" % (