diff options
author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-09-26 21:16:50 +0300 |
---|---|---|
committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-10-05 23:07:52 +0300 |
commit | 1df3c49a1a1c11198d181ddd0ce31bbb42e631d8 (patch) | |
tree | 5a778f559fc9b819466cfeb2d00db40019b27ef1 /tests/multiple_database | |
parent | 93cc6dcdac6fc3e506640fa38dd1798c3cd61cff (diff) | |
download | django-1df3c49a1a1c11198d181ddd0ce31bbb42e631d8.tar.gz |
Fixed #21174 -- transaction control in related manager methods
Diffstat (limited to 'tests/multiple_database')
-rw-r--r-- | tests/multiple_database/tests.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py index 191cbaa154..665de2b604 100644 --- a/tests/multiple_database/tests.py +++ b/tests/multiple_database/tests.py @@ -7,7 +7,7 @@ from operator import attrgetter from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.core import management -from django.db import connections, router, DEFAULT_DB_ALIAS +from django.db import connections, router, DEFAULT_DB_ALIAS, transaction from django.db.models import signals from django.db.utils import ConnectionRouter from django.test import TestCase @@ -490,21 +490,24 @@ class QueryTestCase(TestCase): # Set a foreign key with an object from a different database try: - dive.editor = marty + with transaction.atomic(using='default'): + dive.editor = marty self.fail("Shouldn't be able to assign across databases") except ValueError: pass # Set a foreign key set with an object from a different database try: - marty.edited = [pro, dive] + with transaction.atomic(using='default'): + marty.edited = [pro, dive] self.fail("Shouldn't be able to assign across databases") except ValueError: pass # Add to a foreign key set with an object from a different database try: - marty.edited.add(dive) + with transaction.atomic(using='default'): + marty.edited.add(dive) self.fail("Shouldn't be able to assign across databases") except ValueError: pass |