Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #21029: Test for previously-commited SchemaEditor.__exit__ bug.

  • Loading branch information...
commit 6f7977bb63ea592faaa7b3bdf2898f8361f30260 1 parent ffe21e1
@andrewgodwin andrewgodwin authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 tests/schema/tests.py
View
13 tests/schema/tests.py
@@ -643,3 +643,16 @@ def test_primary_key(self):
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)
Please sign in to comment.
Something went wrong with that request. Please try again.