diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-16 11:04:02 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-16 12:46:35 +0000 |
commit | d50ed488074a3b809bf98fb1e6971bc295ba31c3 (patch) | |
tree | 333d66d7ddf85b5704ccd64a99283862aebbc9f8 /tests/test_async.py | |
parent | b5d80b609d6f1b0922ed51d6182ff137f1b3ba3e (diff) | |
download | psycopg2-d50ed488074a3b809bf98fb1e6971bc295ba31c3.tar.gz |
Added readonly and deferrable attributes
Diffstat (limited to 'tests/test_async.py')
-rwxr-xr-x | tests/test_async.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/test_async.py b/tests/test_async.py index 63a5513..0a386d3 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -26,7 +26,7 @@ from testutils import unittest, skip_before_postgres, slow import psycopg2 -from psycopg2 import extensions +from psycopg2 import extensions as ext import time import StringIO @@ -74,13 +74,14 @@ class AsyncTests(ConnectingTestCase): self.assert_(self.conn.async_) self.assert_(not self.sync_conn.async_) - # the async connection should be in isolevel 0 - self.assertEquals(self.conn.isolation_level, 0) + # the async connection should be autocommit + self.assert_(self.conn.autocommit) + self.assertEquals(self.conn.isolation_level, ext.ISOLATION_LEVEL_DEFAULT) # check other properties to be found on the connection self.assert_(self.conn.server_version) self.assert_(self.conn.protocol_version in (2, 3)) - self.assert_(self.conn.encoding in psycopg2.extensions.encodings) + self.assert_(self.conn.encoding in ext.encodings) def test_async_named_cursor(self): self.assertRaises(psycopg2.ProgrammingError, @@ -192,7 +193,7 @@ class AsyncTests(ConnectingTestCase): # getting transaction status works self.assertEquals(self.conn.get_transaction_status(), - extensions.TRANSACTION_STATUS_ACTIVE) + ext.TRANSACTION_STATUS_ACTIVE) self.assertTrue(self.conn.isexecuting()) # setting connection encoding should fail @@ -311,9 +312,9 @@ class AsyncTests(ConnectingTestCase): self.assertEquals(cur.fetchone()[0], "b" * 10000) def test_async_subclass(self): - class MyConn(psycopg2.extensions.connection): + class MyConn(ext.connection): def __init__(self, dsn, async_=0): - psycopg2.extensions.connection.__init__(self, dsn, async_=async_) + ext.connection.__init__(self, dsn, async_=async_) conn = self.connect(connection_factory=MyConn, async_=True) self.assert_(isinstance(conn, MyConn)) @@ -330,7 +331,7 @@ class AsyncTests(ConnectingTestCase): curs.execute("select %s;", ('x' * size,)) self.wait(stub) self.assertEqual(size, len(curs.fetchone()[0])) - if stub.polls.count(psycopg2.extensions.POLL_WRITE) > 1: + if stub.polls.count(ext.POLL_WRITE) > 1: return # This is more a testing glitch than an error: it happens |