(self)
| 214 | self.assertSequenceEqual(Reporter.objects.all(), []) |
| 215 | |
| 216 | def test_prevent_rollback(self): |
| 217 | with transaction.atomic(): |
| 218 | reporter = Reporter.objects.create(first_name="Tintin") |
| 219 | sid = transaction.savepoint_create() |
| 220 | # trigger a database error inside an inner atomic without savepoint |
| 221 | with self.assertRaises(DatabaseError): |
| 222 | with transaction.atomic(savepoint=False): |
| 223 | with connection.cursor() as cursor: |
| 224 | cursor.execute("SELECT no_such_col FROM transactions_reporter") |
| 225 | # prevent atomic from rolling back since we're recovering manually |
| 226 | self.assertTrue(transaction.get_rollback()) |
| 227 | transaction.set_rollback(False) |
| 228 | transaction.savepoint_rollback(sid) |
| 229 | self.assertSequenceEqual(Reporter.objects.all(), [reporter]) |
| 230 | |
| 231 | @skipUnlessDBFeature("can_release_savepoints") |
| 232 | def test_failure_on_exit_transaction(self): |
nothing calls this directly
no test coverage detected