diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-12 18:26:20 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-12 18:47:03 +0100 |
| commit | cb4a000adbb750da62daab318a9f4da8e3d4fdcd (patch) | |
| tree | 030e983a50fc5eef6c42c8ca029609f6ccfc3d83 /tests/backends | |
| parent | b79bf9c7a9c1bc0e3cf0c5c4b0d8191a3033530b (diff) | |
[1.6.x] Fixed #21452 -- Non-autocommit connections to PostgreSQL.
When settings.DATABASES['default']['AUTOCOMMIT'] = False, the connection
wasn't in autocommit mode but Django pretended it was.
Thanks Anssi for analysing this issue.
Refs #17062.
Backport of 1afe7488 from master
Diffstat (limited to 'tests/backends')
| -rw-r--r-- | tests/backends/tests.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py index be0c3a418f..90794a5472 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -352,10 +352,25 @@ class PostgresNewConnectionTests(TestCase): tz = cursor.fetchone()[0] self.assertEqual(new_tz, tz) finally: - try: - new_connection.close() - except DatabaseError: - pass + new_connection.close() + + @unittest.skipUnless( + connection.vendor == 'postgresql', + "This test applies only to PostgreSQL") + def test_connect_non_autocommit(self): + """ + The connection wrapper shouldn't believe that autocommit is enabled + after setting the time zone when AUTOCOMMIT is False (#21452). + """ + databases = copy.deepcopy(settings.DATABASES) + new_connections = ConnectionHandler(databases) + new_connection = new_connections[DEFAULT_DB_ALIAS] + try: + new_connection.settings_dict['AUTOCOMMIT'] = False + cursor = new_connection.cursor() + self.assertFalse(new_connection.get_autocommit()) + finally: + new_connection.close() # This test needs to run outside of a transaction, otherwise closing the |
