diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2013-09-06 11:46:33 -0500 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2013-09-06 12:16:03 -0500 |
| commit | 6f7977bb63ea592faaa7b3bdf2898f8361f30260 (patch) | |
| tree | 78b6bf834cef0deae1a25c5e3a25b42e0d417835 | |
| parent | ffe21e1f40b99d82d441eb46de323c6bfb0687e9 (diff) | |
Fixed #21029: Test for previously-commited SchemaEditor.__exit__ bug.
| -rw-r--r-- | tests/schema/tests.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index 959f886024..f6125ee9f3 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -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) |
