diff options
| author | Jason Kirtland <jek@discorporate.us> | 2007-08-04 21:25:29 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2007-08-04 21:25:29 +0000 |
| commit | 1223cd15c9aa762a7d4f722b07d32cd8d24174ba (patch) | |
| tree | 9a9abad1c8a903737fa178b7378063d4d40b792d | |
| parent | 4cee19e8f0655b67a0e39e9993b1ed3badf0f6a1 (diff) | |
| download | sqlalchemy-1223cd15c9aa762a7d4f722b07d32cd8d24174ba.tar.gz | |
Added explicit Unicode table_names test
| -rw-r--r-- | test/engine/reflection.py | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/test/engine/reflection.py b/test/engine/reflection.py index 79f12fae4..de7943f46 100644 --- a/test/engine/reflection.py +++ b/test/engine/reflection.py @@ -1,11 +1,11 @@ import testbase -import pickle, StringIO +import pickle, StringIO, unicodedata from sqlalchemy import * import sqlalchemy.ansisql as ansisql from sqlalchemy.exceptions import NoSuchTableError from testlib import * - +from testlib import engines class ReflectionTest(PersistTest): @@ -635,7 +635,36 @@ class CreateDropTest(PersistTest): # template. (*cough* tsearch2 w/ the pg windows installer.) self.assert_(not Set(metadata.tables) - Set(testbase.db.table_names())) metadata.drop_all(bind=testbase.db) - + +class UnicodeTest(PersistTest): + def test_basic(self): + self.assert_(not testbase.db.table_names()) + try: + bind = engines.utf8_engine() + metadata = MetaData(bind) + + names = set([u'plain', u'Unit\u00e9ble', u'\u6e2c\u8a66']) + for name in names: + Table(name, metadata, Column('id', Integer, primary_key=True)) + metadata.create_all() + + reflected = set(bind.table_names()) + if reflected != names: + # Python source files in the utf-8 coding seem to normalize + # literals as NFC (and the above are explicitly NFC). Maybe + # this database normalizes NFD on reflection. + nfc = set([unicodedata.normalize('NFC', n) for n in names]) + self.assert_(nfc == names) + # Yep. But still ensure that bulk reflection and create/drop + # work with either normalization. + + r = MetaData(bind, reflect=True) + r.drop_all() + r.create_all() + finally: + metadata.drop_all() + bind.dispose() + class SchemaTest(PersistTest): # this test should really be in the sql tests somewhere, not engine |
