diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-03 02:38:00 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-03 02:38:00 +0000 |
commit | b8588ef4f76c9d0104bfc53b7af1f99386be4d4c (patch) | |
tree | 1d887aa7c677d45ac2d9ddd143f47f119cbf5af3 /test/testlib/testing.py | |
parent | 90b2a57056f06dc14652517e331cb2609479dbc8 (diff) | |
download | sqlalchemy-b8588ef4f76c9d0104bfc53b7af1f99386be4d4c.tar.gz |
- Dialects can be queried for the server version (sqlite and mysql only with this commit)
- Mark everything in a test suite as failed when setUpAll fails.
- Added test coverage for Unicode table names in metadata.reflect()
- @testing.exclude() filters out tests by server version
- Applied exclude to the test suite, MySQL 4.1 passes again (no XA or SAVEPOINT)
- Removed MySQL charset-setting pool hook- charset=utf8&use_unicode=0 works just as well. (Am I nuts? I'd swear this didn't work before.)
- Finally migrated some old MySQL-tests into the dialect test module
- Corrected 'commit' and 'rollback' logic (and comment) for ancient MySQL versions lacking transactions entirely
- Deprecated the MySQL get_version_info in favor of server_version_info
- Added a big hunk-o-doc for MySQL.
Diffstat (limited to 'test/testlib/testing.py')
-rw-r--r-- | test/testlib/testing.py | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/test/testlib/testing.py b/test/testlib/testing.py index fda85e280..1c6690a78 100644 --- a/test/testlib/testing.py +++ b/test/testlib/testing.py @@ -3,7 +3,7 @@ # monkeypatches unittest.TestLoader.suiteClass at import time import testbase -import unittest, re, sys, os +import unittest, re, sys, os, operator from cStringIO import StringIO import testlib.config as config sql, MetaData, clear_mappers = None, None, None @@ -11,6 +11,14 @@ sql, MetaData, clear_mappers = None, None, None __all__ = 'PersistTest', 'AssertMixin', 'ORMTest' +_ops = { '<': operator.lt, + '>': operator.gt, + '==': operator.eq, + '!=': operator.ne, + '<=': operator.le, + '>=': operator.ge, + 'in': operator.contains } + def unsupported(*dbs): """Mark a test as unsupported by one or more database implementations""" @@ -49,6 +57,41 @@ def supported(*dbs): return maybe return decorate +def exclude(db, op, spec): + """Mark a test as unsupported by specific database server versions. + + Stackable, both with other excludes and supported/unsupported. Examples:: + # Not supported by mydb versions less than 1, 0 + @exclude('mydb', '<', (1,0)) + # Other operators work too + @exclude('bigdb', '==', (9,0,9)) + @exclude('yikesdb', 'in', ((0, 3, 'alpha2'), (0, 3, 'alpha3'))) + """ + + def decorate(fn): + fn_name = fn.__name__ + def maybe(*args, **kw): + if config.db.name != db: + return fn(*args, **kw) + + have = config.db.dialect.server_version_info( + config.db.contextual_connect()) + + oper = hasattr(op, '__call__') and op or _ops[op] + + if oper(have, spec): + print "'%s' unsupported on DB %s version '%s'" % ( + fn_name, config.db.name, have) + return True + else: + return fn(*args, **kw) + try: + maybe.__name__ = fn_name + except: + pass + return maybe + return decorate + class TestData(object): """Tracks SQL expressions as they are executed via an instrumented ExecutionContext.""" @@ -299,8 +342,11 @@ class TTestSuite(unittest.TestSuite): if self._initTest is not None: self._initTest.setUpAll() except: - result.addError(self._initTest, self.__exc_info()) - pass + # skip tests if global setup fails + ex = self.__exc_info() + for test in self._tests: + result.addError(test, ex) + return False try: return self.do_run(result) finally: |