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]) != ("'", "'"):
import testenv; testenv.configure_for_tests()
from testlib import testing, profiling
from sqlalchemy import *
-
+from testlib import set
ITERATIONS = 1
"""
__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):
"""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
testlib.config.configure_defaults()
_setup = True
+
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',
'rowset',
'PersistTest', 'AssertMixin', 'ORMTest', 'SQLCompileTest',
'profiling', 'engines',
- 'set', 'sorted', '_function_named')
+ 'set', 'frozenset', 'sorted', '_function_named')
-import itertools, new
+import itertools, new, sys, warnings
-__all__ = 'set', 'sorted', '_function_named'
+__all__ = 'set', 'frozenset', 'sorted', '_function_named'
try:
set = set
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:
fn = new.function(fn.func_code, fn.func_globals, newname,
fn.func_defaults, fn.func_closure)
return fn
+
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.
# 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)
"""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:
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" % (