mirror of https://github.com/django/django.git
Ensured foreign_object tests reset language properly.
This commit is contained in:
parent
5760fe66df
commit
1da1fe8e16
|
@ -5,7 +5,7 @@ from .models import (
|
||||||
Country, Person, Group, Membership, Friendship, Article,
|
Country, Person, Group, Membership, Friendship, Article,
|
||||||
ArticleTranslation, ArticleTag, ArticleIdea, NewsArticle)
|
ArticleTranslation, ArticleTag, ArticleIdea, NewsArticle)
|
||||||
from django.test import TestCase, skipUnlessDBFeature
|
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.core.exceptions import FieldError
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
|
@ -309,8 +309,8 @@ class MultiColumnFKTests(TestCase):
|
||||||
normal_groups_lists = [list(p.groups.all()) for p in Person.objects.all()]
|
normal_groups_lists = [list(p.groups.all()) for p in Person.objects.all()]
|
||||||
self.assertEqual(groups_lists, normal_groups_lists)
|
self.assertEqual(groups_lists, normal_groups_lists)
|
||||||
|
|
||||||
|
@translation.override('fi')
|
||||||
def test_translations(self):
|
def test_translations(self):
|
||||||
activate('fi')
|
|
||||||
a1 = Article.objects.create(pub_date=datetime.date.today())
|
a1 = Article.objects.create(pub_date=datetime.date.today())
|
||||||
at1_fi = ArticleTranslation(article=a1, lang='fi', title='Otsikko', body='Diipadaapa')
|
at1_fi = ArticleTranslation(article=a1, lang='fi', title='Otsikko', body='Diipadaapa')
|
||||||
at1_fi.save()
|
at1_fi.save()
|
||||||
|
@ -338,7 +338,8 @@ class MultiColumnFKTests(TestCase):
|
||||||
list(Article.objects.filter(active_translation__abstract=None,
|
list(Article.objects.filter(active_translation__abstract=None,
|
||||||
active_translation__pk__isnull=False)),
|
active_translation__pk__isnull=False)),
|
||||||
[a1])
|
[a1])
|
||||||
activate('en')
|
|
||||||
|
with translation.override('en'):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
list(Article.objects.filter(active_translation__abstract=None)),
|
list(Article.objects.filter(active_translation__abstract=None)),
|
||||||
[a1, a2])
|
[a1, a2])
|
||||||
|
@ -365,8 +366,8 @@ class MultiColumnFKTests(TestCase):
|
||||||
with self.assertRaises(FieldError):
|
with self.assertRaises(FieldError):
|
||||||
Article.objects.filter(ideas__name="idea1")
|
Article.objects.filter(ideas__name="idea1")
|
||||||
|
|
||||||
|
@translation.override('fi')
|
||||||
def test_inheritance(self):
|
def test_inheritance(self):
|
||||||
activate("fi")
|
|
||||||
na = NewsArticle.objects.create(pub_date=datetime.date.today())
|
na = NewsArticle.objects.create(pub_date=datetime.date.today())
|
||||||
ArticleTranslation.objects.create(
|
ArticleTranslation.objects.create(
|
||||||
article=na, lang="fi", title="foo", body="bar")
|
article=na, lang="fi", title="foo", body="bar")
|
||||||
|
|
Loading…
Reference in New Issue