summaryrefslogtreecommitdiff
path: root/tests/regressiontests/multiple_database
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2012-10-26 08:41:13 +0100
committerAndrew Godwin <andrew@aeracode.org>2012-10-26 08:41:13 +0100
commit6a632e04578776e877adc5e2dc53f008c890a0d4 (patch)
treeaa47200fb63adf44609066a45601bd3b8768ec1c /tests/regressiontests/multiple_database
parenta589fdff81ab36c57ff0a1003e60ee0dd55f3a88 (diff)
parentfabe9c9e5f0a437b5389faaf469ce53091abd3cf (diff)
Merge branch 'master' into schema-alteration
Conflicts: django/db/backends/__init__.py django/db/models/fields/related.py django/db/models/options.py
Diffstat (limited to 'tests/regressiontests/multiple_database')
-rw-r--r--tests/regressiontests/multiple_database/tests.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index 782fe2bfc6..79fe6beebd 100644
--- a/tests/regressiontests/multiple_database/tests.py
+++ b/tests/regressiontests/multiple_database/tests.py
@@ -4,13 +4,13 @@ import datetime
import pickle
from operator import attrgetter
-from django.conf import settings
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.models import signals
from django.test import TestCase
+from django.test.utils import override_settings
from django.utils.six import StringIO
from .models import Book, Person, Pet, Review, UserProfile
@@ -652,7 +652,8 @@ class QueryTestCase(TestCase):
new_bob_profile = UserProfile(flavor="spring surprise")
- charlie = User(username='charlie',email='charlie@example.com')
+ # assigning a profile requires a explicit pk as the object isn't saved
+ charlie = User(pk=51, username='charlie', email='charlie@example.com')
charlie.set_unusable_password()
# initially, no db assigned
@@ -1619,20 +1620,11 @@ class AuthTestCase(TestCase):
command_output = new_io.getvalue().strip()
self.assertTrue('"email": "alice@example.com",' in command_output)
-_missing = object()
-class UserProfileTestCase(TestCase):
- def setUp(self):
- self.old_auth_profile_module = getattr(settings, 'AUTH_PROFILE_MODULE', _missing)
- settings.AUTH_PROFILE_MODULE = 'multiple_database.UserProfile'
- def tearDown(self):
- if self.old_auth_profile_module is _missing:
- del settings.AUTH_PROFILE_MODULE
- else:
- settings.AUTH_PROFILE_MODULE = self.old_auth_profile_module
+@override_settings(AUTH_PROFILE_MODULE='multiple_database.UserProfile')
+class UserProfileTestCase(TestCase):
def test_user_profiles(self):
-
alice = User.objects.create_user('alice', 'alice@example.com')
bob = User.objects.db_manager('other').create_user('bob', 'bob@example.com')