mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #21029: Test for previously-commited SchemaEditor.__exit__ bug.
This commit is contained in:
		| @@ -643,3 +643,16 @@ class SchemaTests(TransactionTestCase): | ||||
|         self.assertTrue( | ||||
|             connection.introspection.get_indexes(connection.cursor(), Tag._meta.db_table)['slug']['primary_key'], | ||||
|         ) | ||||
|  | ||||
|     def test_context_manager_exit(self): | ||||
|         """ | ||||
|         Ensures transaction is correctly closed when an error occurs | ||||
|         inside a SchemaEditor context. | ||||
|         """ | ||||
|         class SomeError(Exception): | ||||
|             pass | ||||
|         try: | ||||
|             with connection.schema_editor() as editor: | ||||
|                 raise SomeError | ||||
|         except SomeError: | ||||
|             self.assertFalse(connection.in_atomic_block) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user