diff options
| author | Jason Kirtland <jek@discorporate.us> | 2008-01-22 21:08:21 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2008-01-22 21:08:21 +0000 |
| commit | b3cc2f7e0c308354f3f939c47c382a2d11845d4f (patch) | |
| tree | 6da3c9cf38346942b868555e696068c19b8b505e /test | |
| parent | 5bc0fe9e16e94dd2ed16b7bf393cef0b9a4ceb25 (diff) | |
| download | sqlalchemy-b3cc2f7e0c308354f3f939c47c382a2d11845d4f.tar.gz | |
- 2.3 fixup part three: 100% on postgres, mysql
Diffstat (limited to 'test')
| -rw-r--r-- | test/profiling/zoomark.py | 3 | ||||
| -rw-r--r-- | test/testenv.py | 7 | ||||
| -rw-r--r-- | test/testlib/__init__.py | 4 | ||||
| -rw-r--r-- | test/testlib/compat.py | 11 | ||||
| -rw-r--r-- | test/testlib/testing.py | 20 |
5 files changed, 39 insertions, 6 deletions
diff --git a/test/profiling/zoomark.py b/test/profiling/zoomark.py index 8c46f4188..d7ef0bf52 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 bdfd6efc0..35e9032aa 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 46852191a..49ef0ca8a 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 8d2b35d4a..4f2006afd 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 @@ -52,6 +52,12 @@ except NameError: return sets.Set.__isub__(self, other) try: + frozenset = frozenset +except NameError: + import sets + from sets import ImmutableSet as frozenset + +try: sorted = sorted except NameError: def sorted(iterable, cmp=None): @@ -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 8b64ce7db..cb10cf61a 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" % ( |
