Kaydet (Commit) d895fc9a authored tarafından Claude Paroz's avatar Claude Paroz Kaydeden (comit) Tim Graham

Refs #16682 -- Tested transaction.atomic() with KeyboardInterrupt.

üst ddef397b
from __future__ import unicode_literals
import os
import sys
import threading
import time
......@@ -218,6 +219,18 @@ class AtomicTests(TransactionTestCase):
transaction.savepoint_rollback(sid)
self.assertQuerysetEqual(Reporter.objects.all(), ['<Reporter: Tintin>'])
@skipIf(sys.platform.startswith('win'), "Windows doesn't have signals.")
def test_rollback_on_keyboardinterrupt(self):
try:
with transaction.atomic():
Reporter.objects.create(first_name='Tintin')
# Send SIGINT (simulate Ctrl-C). One call isn't enough.
os.kill(os.getpid(), 2)
os.kill(os.getpid(), 2)
except KeyboardInterrupt:
pass
self.assertEqual(Reporter.objects.all().count(), 0)
class AtomicInsideTransactionTests(AtomicTests):
"""All basic tests for atomic should also pass within an existing transaction."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment