(self)
| 278 | available_apps = ["transactions"] |
| 279 | |
| 280 | def test_merged_outer_rollback(self): |
| 281 | with transaction.atomic(): |
| 282 | Reporter.objects.create(first_name="Tintin") |
| 283 | with transaction.atomic(savepoint=False): |
| 284 | Reporter.objects.create(first_name="Archibald", last_name="Haddock") |
| 285 | with self.assertRaisesMessage(Exception, "Oops"): |
| 286 | with transaction.atomic(savepoint=False): |
| 287 | Reporter.objects.create(first_name="Calculus") |
| 288 | raise Exception("Oops, that's his last name") |
| 289 | # The third insert couldn't be roll back. Temporarily mark the |
| 290 | # connection as not needing rollback to check it. |
| 291 | self.assertTrue(transaction.get_rollback()) |
| 292 | transaction.set_rollback(False) |
| 293 | self.assertEqual(Reporter.objects.count(), 3) |
| 294 | transaction.set_rollback(True) |
| 295 | # The second insert couldn't be roll back. Temporarily mark the |
| 296 | # connection as not needing rollback to check it. |
| 297 | self.assertTrue(transaction.get_rollback()) |
| 298 | transaction.set_rollback(False) |
| 299 | self.assertEqual(Reporter.objects.count(), 3) |
| 300 | transaction.set_rollback(True) |
| 301 | # The first block has a savepoint and must roll back. |
| 302 | self.assertSequenceEqual(Reporter.objects.all(), []) |
| 303 | |
| 304 | def test_merged_inner_savepoint_rollback(self): |
| 305 | with transaction.atomic(): |
nothing calls this directly
no test coverage detected