diff options
Diffstat (limited to 'tests/test_async.py')
-rwxr-xr-x | tests/test_async.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/test_async.py b/tests/test_async.py index 08113c4..09604b5 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -32,7 +32,7 @@ import time import select import StringIO -from testconfig import dsn +from testutils import ConnectingTestCase class PollableStub(object): """A 'pollable' wrapper allowing analysis of the `poll()` calls.""" @@ -49,11 +49,13 @@ class PollableStub(object): return rv -class AsyncTests(unittest.TestCase): +class AsyncTests(ConnectingTestCase): def setUp(self): - self.sync_conn = psycopg2.connect(dsn) - self.conn = psycopg2.connect(dsn, async=True) + ConnectingTestCase.setUp(self) + + self.sync_conn = self.conn + self.conn = self.connect(async=True) self.wait(self.conn) @@ -64,10 +66,6 @@ class AsyncTests(unittest.TestCase): )''') self.wait(curs) - def tearDown(self): - self.sync_conn.close() - self.conn.close() - def wait(self, cur_or_conn): pollable = cur_or_conn if not hasattr(pollable, 'poll'): @@ -328,7 +326,7 @@ class AsyncTests(unittest.TestCase): def __init__(self, dsn, async=0): psycopg2.extensions.connection.__init__(self, dsn, async=async) - conn = psycopg2.connect(dsn, connection_factory=MyConn, async=True) + conn = self.connect(connection_factory=MyConn, async=True) self.assert_(isinstance(conn, MyConn)) self.assert_(conn.async) conn.close() @@ -429,6 +427,9 @@ class AsyncTests(unittest.TestCase): def test_notices(self): del self.conn.notices[:] cur = self.conn.cursor() + if self.conn.server_version >= 90300: + cur.execute("set client_min_messages=debug1") + self.wait(cur) cur.execute("create temp table chatty (id serial primary key);") self.wait(cur) self.assertEqual("CREATE TABLE", cur.statusmessage) |