diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-25 17:02:50 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-03-25 17:02:50 -0400 |
commit | 3f0bd7269bda6a9fa833c7d6ba2f393688ffd524 (patch) | |
tree | c1e3f6fd97305bcc67defaf877075c446a38dbdc /test/dialect/test_postgresql.py | |
parent | 48de61c9574d223fc2622d56903340fc1fa4ded1 (diff) | |
download | sqlalchemy-3f0bd7269bda6a9fa833c7d6ba2f393688ffd524.tar.gz |
- The psycopg2 dialect will log NOTICE messages via the
"sqlalchemy.dialects.postgresql" logger name.
[ticket:877]
Diffstat (limited to 'test/dialect/test_postgresql.py')
-rw-r--r-- | test/dialect/test_postgresql.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 472b12e50..bc3fbc614 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -13,6 +13,7 @@ from sqlalchemy.test.util import round_decimal from sqlalchemy.sql import table, column from sqlalchemy.test.testing import eq_ from test.engine._base import TablesTest +import logging class SequenceTest(TestBase, AssertsCompiledSQL): def test_basic(self): @@ -395,9 +396,6 @@ class EnumTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): finally: metadata.drop_all() - - - class InsertTest(TestBase, AssertsExecutionResults): __only_on__ = 'postgresql' @@ -964,7 +962,6 @@ class DomainReflectionTest(TestBase, AssertsExecutionResults): finally: postgresql.PGDialect.ischema_names = ischema_names - class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): __only_on__ = 'postgresql' @@ -1001,6 +998,29 @@ class MiscTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): ]: eq_(testing.db.dialect._get_server_version_info(MockConn(string)), version) + + @testing.only_on('postgresql+psycopg2', 'psycopg2-specific feature') + def test_notice_logging(self): + log = logging.getLogger('sqlalchemy.dialects.postgresql') + buf = logging.handlers.BufferingHandler(100) + lev = log.level + log.addHandler(buf) + log.setLevel(logging.INFO) + try: + conn = testing.db.connect() + trans = conn.begin() + try: + conn.execute("create table foo (id serial primary key)") + finally: + trans.rollback() + finally: + log.removeHandler(buf) + log.setLevel(lev) + + msgs = " ".join(b.msg for b in buf.buffer) + assert "will create implicit sequence" in msgs + assert "will create implicit index" in msgs + def test_pg_weirdchar_reflection(self): meta1 = MetaData(testing.db) |