diff options
author | Federico Di Gregorio <fog@initd.org> | 2011-12-15 12:22:52 +0100 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2011-12-15 12:25:19 +0100 |
commit | d2d94e203f868d17d4e7ff670078a7df7afbad90 (patch) | |
tree | dc94e3441eb93a3f95a9cddc2a8b3af837419b5d /tests/test_connection.py | |
parent | 8473209d240bad964630b9b77da7fcc664f61b41 (diff) | |
download | psycopg2-d2d94e203f868d17d4e7ff670078a7df7afbad90.tar.gz |
Reverted isolation level values to backward compatible values
This basically removes the READ UNCOMMITED level (that internally
PostgreSQL maps to READ COMMITED anyway) to keep the numeric values
compattible with old psycopg versions. For full details and discussion
see this thread:
http://archives.postgresql.org/psycopg/2011-12/msg00008.php
Diffstat (limited to 'tests/test_connection.py')
-rwxr-xr-x | tests/test_connection.py | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py index a887313..0a79144 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -206,7 +206,6 @@ class IsolationLevelsTestCase(unittest.TestCase): levels = [ (None, psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT), - ('read uncommitted', psycopg2.extensions.ISOLATION_LEVEL_READ_UNCOMMITTED), ('read committed', psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED), ('repeatable read', psycopg2.extensions.ISOLATION_LEVEL_REPEATABLE_READ), ('serializable', psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE), @@ -216,10 +215,8 @@ class IsolationLevelsTestCase(unittest.TestCase): # the only values available on prehistoric PG versions if conn.server_version < 80000: - if level in ( - psycopg2.extensions.ISOLATION_LEVEL_READ_UNCOMMITTED, - psycopg2.extensions.ISOLATION_LEVEL_REPEATABLE_READ): - name, level = levels[levels.index((name, level)) + 1] + if level == psycopg2.extensions.ISOLATION_LEVEL_REPEATABLE_READ: + name, level = ('serializable', psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE) self.assertEqual(conn.isolation_level, level) @@ -771,13 +768,11 @@ class TransactionControlTests(unittest.TestCase): self.assertEqual(cur.fetchone()[0], 'read committed') self.conn.rollback() + # 'read uncommitted' is internally translated to 'read committed' self.conn.set_session( isolation_level=psycopg2.extensions.ISOLATION_LEVEL_READ_UNCOMMITTED) cur.execute("SHOW default_transaction_isolation;") - if self.conn.server_version > 80000: - self.assertEqual(cur.fetchone()[0], 'read uncommitted') - else: - self.assertEqual(cur.fetchone()[0], 'read committed') + self.assertEqual(cur.fetchone()[0], 'read committed') self.conn.rollback() def test_set_isolation_level_str(self): |