diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-01-09 22:54:51 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-01-09 22:54:51 +0000 |
commit | 84576e3258ea05b044f90463e8a59541661d5931 (patch) | |
tree | bb270f23d8f9b53a58e2f1523733d714d2f45fde /test/engine/reflection.py | |
parent | 046ec98a0bb5065b931911aa3e3a3ec6fe9f8507 (diff) | |
download | sqlalchemy-84576e3258ea05b044f90463e8a59541661d5931.tar.gz |
test suite deprecation rampage
Diffstat (limited to 'test/engine/reflection.py')
-rw-r--r-- | test/engine/reflection.py | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/test/engine/reflection.py b/test/engine/reflection.py index 8b4fec50d..a3b42bf6e 100644 --- a/test/engine/reflection.py +++ b/test/engine/reflection.py @@ -1,5 +1,5 @@ import testbase -import pickle, StringIO, unicodedata +import pickle, StringIO, unicodedata, warnings from sqlalchemy import * from sqlalchemy import exceptions @@ -183,34 +183,45 @@ class ReflectionTest(PersistTest): assert len(a4.constraints) == 2 finally: meta.drop_all() - + def test_unknown_types(self): meta = MetaData(testbase.db) - t = Table("test", meta, + t = Table("test", meta, Column('foo', DateTime)) - + import sys dialect_module = sys.modules[testbase.db.dialect.__module__] - - # we're relying on the presence of "ischema_names" in the + + # we're relying on the presence of "ischema_names" in the # dialect module, else we can't test this. we need to be able # to get the dialect to not be aware of some type so we temporarily # monkeypatch. not sure what a better way for this could be, # except for an established dialect hook or dialect-specific tests if not hasattr(dialect_module, 'ischema_names'): return - + ischema_names = dialect_module.ischema_names t.create() dialect_module.ischema_names = {} try: - m2 = MetaData(testbase.db) - t2 = Table("test", m2, autoload=True) - assert t2.c.foo.type.__class__ == sqltypes.NullType + try: + warnings.filterwarnings('error', 'Did not recognize type') + m2 = MetaData(testbase.db) + t2 = Table("test", m2, autoload=True) + assert False + except RuntimeWarning: + assert True + + warnings.filterwarnings('ignore', 'Did not recognize type') + m3 = MetaData(testbase.db) + t3 = Table("test", m3, autoload=True) + assert t3.c.foo.type.__class__ == sqltypes.NullType + finally: dialect_module.ischema_names = ischema_names + warnings.filterwarnings('always', 'Did not recognize type') t.drop() - + def test_override_fkandpkcol(self): """test that you can override columns which contain foreign keys to other reflected tables, where the foreign key column is also a primary key column""" @@ -316,7 +327,7 @@ class ReflectionTest(PersistTest): slots_table = Table('slots', metadata, Column('slot_id', Integer, primary_key=True), Column('pkg_id', Integer, ForeignKey('pkgs.pkg_id')), - Column('slot', String), + Column('slot', String(128)), ) try: metadata.create_all() @@ -676,7 +687,7 @@ class UnicodeTest(PersistTest): def test_basic(self): try: - # the 'convert_unicode' should not get in the way of the reflection + # the 'convert_unicode' should not get in the way of the reflection # process. reflecttable for oracle, postgres (others?) expect non-unicode # strings in result sets/bind params bind = engines.utf8_engine(options={'convert_unicode':True}) @@ -710,7 +721,7 @@ class UnicodeTest(PersistTest): class SchemaTest(PersistTest): - + # this test should really be in the sql tests somewhere, not engine def test_iteration(self): metadata = MetaData() |