mirror of
				https://github.com/django/django.git
				synced 2025-10-30 09:06:13 +00:00 
			
		
		
		
	[1.6.x] Fixed a test isolation issue. Refs #17062.
This test could change settings.DATABASES['default']['TIME_ZONE'] and
didn't restore the previous value.
Backport of 1c24096f from master.
			
			
This commit is contained in:
		| @@ -2,6 +2,7 @@ | |||||||
| # Unit and doctests for specific database backends. | # Unit and doctests for specific database backends. | ||||||
| from __future__ import absolute_import, unicode_literals | from __future__ import absolute_import, unicode_literals | ||||||
|  |  | ||||||
|  | import copy | ||||||
| import datetime | import datetime | ||||||
| from decimal import Decimal | from decimal import Decimal | ||||||
| import threading | import threading | ||||||
| @@ -315,16 +316,18 @@ class PostgresVersionTest(TestCase): | |||||||
|         self.assertEqual(pg_version.get_version(conn), 80300) |         self.assertEqual(pg_version.get_version(conn), 80300) | ||||||
|  |  | ||||||
|  |  | ||||||
| class PostgresNewConnectionTest(TestCase): | class PostgresNewConnectionTests(TestCase): | ||||||
|     """ |  | ||||||
|     #17062: PostgreSQL shouldn't roll back SET TIME ZONE, even if the first |  | ||||||
|     transaction is rolled back. |  | ||||||
|     """ |  | ||||||
|     @unittest.skipUnless( |     @unittest.skipUnless( | ||||||
|         connection.vendor == 'postgresql', |         connection.vendor == 'postgresql', | ||||||
|         "This test applies only to PostgreSQL") |         "This test applies only to PostgreSQL") | ||||||
|     def test_connect_and_rollback(self): |     def test_connect_and_rollback(self): | ||||||
|         new_connections = ConnectionHandler(settings.DATABASES) |         """ | ||||||
|  |         PostgreSQL shouldn't roll back SET TIME ZONE, even if the first | ||||||
|  |         transaction is rolled back (#17062). | ||||||
|  |         """ | ||||||
|  |         databases = copy.deepcopy(settings.DATABASES) | ||||||
|  |         new_connections = ConnectionHandler(databases) | ||||||
|         new_connection = new_connections[DEFAULT_DB_ALIAS] |         new_connection = new_connections[DEFAULT_DB_ALIAS] | ||||||
|         try: |         try: | ||||||
|             # Ensure the database default time zone is different than |             # Ensure the database default time zone is different than | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user