Browse files

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

  • Loading branch information...
1 parent ffe21e1 commit 6f7977bb63ea592faaa7b3bdf2898f8361f30260 @andrewgodwin andrewgodwin committed Sep 6, 2013
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)

0 comments on commit 6f7977b

Please sign in to comment.