summaryrefslogtreecommitdiff
path: root/tests/foreign_object
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2014-12-01 22:51:16 -0600
committerTim Graham <timograham@gmail.com>2014-12-02 07:31:52 -0500
commit1da1fe8e16e4f49447f7fb94fb092cfeafff7058 (patch)
treed1726367fc149656339100ad90b0edfa9dbde600 /tests/foreign_object
parent5760fe66dfa19eb38dc7c335d7a360e533b7a352 (diff)
downloaddjango-1da1fe8e16e4f49447f7fb94fb092cfeafff7058.tar.gz
Ensured foreign_object tests reset language properly.
Diffstat (limited to 'tests/foreign_object')
-rw-r--r--tests/foreign_object/tests.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py
index fd34a05013..dc949a3526 100644
--- a/tests/foreign_object/tests.py
+++ b/tests/foreign_object/tests.py
@@ -5,7 +5,7 @@ from .models import (
Country, Person, Group, Membership, Friendship, Article,
ArticleTranslation, ArticleTag, ArticleIdea, NewsArticle)
from django.test import TestCase, skipUnlessDBFeature
-from django.utils.translation import activate
+from django.utils import translation
from django.core.exceptions import FieldError
from django import forms
@@ -309,8 +309,8 @@ class MultiColumnFKTests(TestCase):
normal_groups_lists = [list(p.groups.all()) for p in Person.objects.all()]
self.assertEqual(groups_lists, normal_groups_lists)
+ @translation.override('fi')
def test_translations(self):
- activate('fi')
a1 = Article.objects.create(pub_date=datetime.date.today())
at1_fi = ArticleTranslation(article=a1, lang='fi', title='Otsikko', body='Diipadaapa')
at1_fi.save()
@@ -338,10 +338,11 @@ class MultiColumnFKTests(TestCase):
list(Article.objects.filter(active_translation__abstract=None,
active_translation__pk__isnull=False)),
[a1])
- activate('en')
- self.assertEqual(
- list(Article.objects.filter(active_translation__abstract=None)),
- [a1, a2])
+
+ with translation.override('en'):
+ self.assertEqual(
+ list(Article.objects.filter(active_translation__abstract=None)),
+ [a1, a2])
def test_foreign_key_raises_informative_does_not_exist(self):
referrer = ArticleTranslation()
@@ -365,8 +366,8 @@ class MultiColumnFKTests(TestCase):
with self.assertRaises(FieldError):
Article.objects.filter(ideas__name="idea1")
+ @translation.override('fi')
def test_inheritance(self):
- activate("fi")
na = NewsArticle.objects.create(pub_date=datetime.date.today())
ArticleTranslation.objects.create(
article=na, lang="fi", title="foo", body="bar")