summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2007-10-26 20:21:10 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2007-10-26 20:21:10 +0000
commit1746760500a3232e7752626fc33deda7f6b74862 (patch)
treea6fabb90eb3cff113f93757ca85bc8140ea85d59 /tests
parent11b6e1eeb788e8679a6d6d42944471aa3998819d (diff)
newforms-admin: Merged to [6612]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@6613 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/invalid_models/models.py6
-rw-r--r--tests/regressiontests/auth_backends/tests.py30
-rw-r--r--tests/regressiontests/cache/tests.py6
-rw-r--r--tests/regressiontests/datastructures/tests.py19
-rw-r--r--tests/regressiontests/forms/localflavor/pl.py30
-rw-r--r--tests/regressiontests/forms/models.py50
-rw-r--r--tests/regressiontests/forms/tests.py2
-rw-r--r--tests/regressiontests/forms/widgets.py23
-rw-r--r--tests/regressiontests/i18n/misc.py57
-rw-r--r--tests/regressiontests/i18n/tests.py8
-rw-r--r--tests/regressiontests/templates/tests.py23
-rw-r--r--tests/regressiontests/text/tests.py4
-rw-r--r--tests/regressiontests/utils/tests.py28
-rwxr-xr-xtests/runtests.py3
14 files changed, 253 insertions, 36 deletions
diff --git a/tests/modeltests/invalid_models/models.py b/tests/modeltests/invalid_models/models.py
index 3372dac518..0ae035f774 100644
--- a/tests/modeltests/invalid_models/models.py
+++ b/tests/modeltests/invalid_models/models.py
@@ -13,6 +13,7 @@ class FieldErrors(models.Model):
choices = models.CharField(max_length=10, choices='bad')
choices2 = models.CharField(max_length=10, choices=[(1,2,3),(1,2,3)])
index = models.CharField(max_length=10, db_index='bad')
+ field_ = models.CharField(max_length=10)
class Target(models.Model):
tgt_safe = models.CharField(max_length=10)
@@ -46,7 +47,7 @@ class Target2(models.Model):
class Clash3(models.Model):
src_safe = models.CharField(max_length=10, core=True)
-
+
foreign_1 = models.ForeignKey(Target2, related_name='foreign_tgt')
foreign_2 = models.ForeignKey(Target2, related_name='m2m_tgt')
@@ -75,7 +76,7 @@ class ValidM2M(models.Model):
# on self don't require a related accessor, so many potential
# clashes are avoided.
validm2m_set = models.ManyToManyField("ValidM2M")
-
+
m2m_1 = models.ManyToManyField("ValidM2M", related_name='id')
m2m_2 = models.ManyToManyField("ValidM2M", related_name='src_safe')
@@ -114,6 +115,7 @@ invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tup
invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.
invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.
invalid_models.fielderrors: "index": "db_index" should be either None, True or False.
+invalid_models.fielderrors: "field_": Field names cannot end with underscores, because this would lead to ambiguous queryset filters.
invalid_models.clash1: Accessor for field 'foreign' clashes with field 'Target.clash1_set'. Add a related_name argument to the definition for 'foreign'.
invalid_models.clash1: Accessor for field 'foreign' clashes with related m2m field 'Target.clash1_set'. Add a related_name argument to the definition for 'foreign'.
invalid_models.clash1: Reverse query name for field 'foreign' clashes with field 'Target.clash1'. Add a related_name argument to the definition for 'foreign'.
diff --git a/tests/regressiontests/auth_backends/tests.py b/tests/regressiontests/auth_backends/tests.py
index 71e58442e7..3ec2a059ad 100644
--- a/tests/regressiontests/auth_backends/tests.py
+++ b/tests/regressiontests/auth_backends/tests.py
@@ -1,4 +1,9 @@
-"""
+try:
+ set
+except NameError:
+ from sets import Set as set # Python 2.3 fallback
+
+__test__ = {'API_TESTS': """
>>> from django.contrib.auth.models import User, Group, Permission
>>> from django.contrib.contenttypes.models import ContentType
@@ -28,10 +33,10 @@ False
# reloading user to purge the _perm_cache
>>> user = User.objects.get(username="test")
->>> user.get_all_permissions()
-set([u'auth.test'])
->>> user.get_group_permissions()
-set([])
+>>> user.get_all_permissions() == set([u'auth.test'])
+True
+>>> user.get_group_permissions() == set([])
+True
>>> user.has_module_perms("Group")
False
>>> user.has_module_perms("auth")
@@ -43,8 +48,8 @@ True
>>> user.user_permissions.add(perm)
>>> user.save()
>>> user = User.objects.get(username="test")
->>> user.get_all_permissions()
-set([u'auth.test2', u'auth.test', u'auth.test3'])
+>>> user.get_all_permissions() == set([u'auth.test2', u'auth.test', u'auth.test3'])
+True
>>> user.has_perm('test')
False
>>> user.has_perm('auth.test')
@@ -57,10 +62,11 @@ True
>>> group.save()
>>> user.groups.add(group)
>>> user = User.objects.get(username="test")
->>> user.get_all_permissions()
-set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
->>> user.get_group_permissions()
-set([u'auth.test_group'])
+>>> exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
+>>> user.get_all_permissions() == exp
+True
+>>> user.get_group_permissions() == set([u'auth.test_group'])
+True
>>> user.has_perms(['auth.test3', 'auth.test_group'])
True
-""" \ No newline at end of file
+"""}
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 752083bd2f..3879da7703 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -19,6 +19,12 @@ class Cache(unittest.TestCase):
cache.set("key", "value")
self.assertEqual(cache.get("key"), "value")
+ def test_add(self):
+ # test add (only add if key isn't already in cache)
+ cache.add("addkey1", "value")
+ cache.add("addkey1", "newvalue")
+ self.assertEqual(cache.get("addkey1"), "value")
+
def test_non_existent(self):
# get with non-existent keys
self.assertEqual(cache.get("does_not_exist"), None)
diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py
index 3920e1ca40..d1e21e673c 100644
--- a/tests/regressiontests/datastructures/tests.py
+++ b/tests/regressiontests/datastructures/tests.py
@@ -54,6 +54,25 @@
True
>>> print repr(d)
{'one': 'not one', 'two': 'two', 'three': 'three'}
+>>> d.pop('one', 'missing')
+'not one'
+>>> d.pop('one', 'missing')
+'missing'
+
+We don't know which item will be popped in popitem(), so we'll just check that
+the number of keys has decreased.
+>>> l = len(d)
+>>> _ = d.popitem()
+>>> l - len(d)
+1
+
+Init from sequence of tuples
+>>> d = SortedDict((
+... (1, "one"),
+... (0, "zero"),
+... (2, "two")))
+>>> print repr(d)
+{1: 'one', 0: 'zero', 2: 'two'}
### DotExpandedDict ############################################################
diff --git a/tests/regressiontests/forms/localflavor/pl.py b/tests/regressiontests/forms/localflavor/pl.py
index be8437208b..becdda8a1d 100644
--- a/tests/regressiontests/forms/localflavor/pl.py
+++ b/tests/regressiontests/forms/localflavor/pl.py
@@ -35,11 +35,15 @@ u'41-403'
Traceback (most recent call last):
...
ValidationError: [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.']
->>> f.clean('43-34-234-323')
-u'43-34-234-323'
->>> f.clean('433-344-24-23')
-u'433-344-24-23'
-
+>>> f.clean('64-62-414-124')
+u'6462414124'
+>>> f.clean('646-241-41-24')
+u'6462414124'
+>>> f.clean('646-241-41-23')
+Traceback (most recent call last):
+...
+ValidationError: [u'Wrong checksum for the Tax Number (NIP).']
+
# PLNationalIdentificationNumberField ############################################
>>> from django.contrib.localflavor.pl.forms import PLNationalIdentificationNumberField
@@ -58,4 +62,20 @@ ValidationError: [u'National Identification Number consists of 11 digits.']
Traceback (most recent call last):
...
ValidationError: [u'National Identification Number consists of 11 digits.']
+
+# PLNationalBusinessRegisterField ################################################
+
+>>> from django.contrib.localflavor.pl.forms import PLNationalBusinessRegisterField
+>>> f = PLNationalBusinessRegisterField()
+>>> f.clean('590096454')
+u'590096454'
+>>> f.clean('590096453')
+Traceback (most recent call last):
+...
+ValidationError: [u'Wrong checksum for the National Business Register Number (REGON).']
+>>> f.clean('590096')
+Traceback (most recent call last):
+...
+ValidationError: [u'National Business Register Number (REGON) consists of 7 or 9 digits.']
+
"""
diff --git a/tests/regressiontests/forms/models.py b/tests/regressiontests/forms/models.py
index f4f8607193..1a6f566b6b 100644
--- a/tests/regressiontests/forms/models.py
+++ b/tests/regressiontests/forms/models.py
@@ -1,21 +1,49 @@
+import datetime
+
from django.db import models
-class BoundaryModel(models.Model):
+class BoundaryModel(models.Model):
positive_integer = models.PositiveIntegerField(null=True, blank=True)
-
+
+class Defaults(models.Model):
+ name = models.CharField(max_length=256, default='class default value')
+ def_date = models.DateField(default = datetime.date(1980, 1, 1))
+ value = models.IntegerField(default=42)
+
__test__ = {'API_TESTS': """
->>> from django.newforms import form_for_model
+>>> from django.newforms import form_for_model, form_for_instance
# Boundary conditions on a PostitiveIntegerField #########################
->>> BoundaryForm = form_for_model(BoundaryModel)
->>> f = BoundaryForm({'positive_integer':100})
->>> f.is_valid()
+>>> BoundaryForm = form_for_model(BoundaryModel)
+>>> f = BoundaryForm({'positive_integer':100})
+>>> f.is_valid()
True
->>> f = BoundaryForm({'positive_integer':0})
->>> f.is_valid()
+>>> f = BoundaryForm({'positive_integer':0})
+>>> f.is_valid()
True
->>> f = BoundaryForm({'positive_integer':-100})
->>> f.is_valid()
+>>> f = BoundaryForm({'positive_integer':-100})
+>>> f.is_valid()
False
-"""} \ No newline at end of file
+# Formfield initial values ########
+If the model has default values for some fields, they are used as the formfield
+initial values.
+>>> DefaultsForm = form_for_model(Defaults)
+>>> DefaultsForm().fields['name'].initial
+u'class default value'
+>>> DefaultsForm().fields['def_date'].initial
+datetime.date(1980, 1, 1)
+>>> DefaultsForm().fields['value'].initial
+42
+
+In form_for_instance(), the initial values come from the instance's values, not
+the model's defaults.
+>>> foo_instance = Defaults(name=u'instance value', def_date = datetime.date(1969, 4, 4), value = 12)
+>>> InstanceForm = form_for_instance(foo_instance)
+>>> InstanceForm().fields['name'].initial
+u'instance value'
+>>> InstanceForm().fields['def_date'].initial
+datetime.date(1969, 4, 4)
+>>> InstanceForm().fields['value'].initial
+12
+"""}
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index 49f03da798..e90d6d2510 100644
--- a/tests/regressiontests/forms/tests.py
+++ b/tests/regressiontests/forms/tests.py
@@ -9,6 +9,7 @@ from localflavor.ca import tests as localflavor_ca_tests
from localflavor.ch import tests as localflavor_ch_tests
from localflavor.cl import tests as localflavor_cl_tests
from localflavor.de import tests as localflavor_de_tests
+from localflavor.es import tests as localflavor_es_tests
from localflavor.fi import tests as localflavor_fi_tests
from localflavor.fr import tests as localflavor_fr_tests
from localflavor.generic import tests as localflavor_generic_tests
@@ -37,6 +38,7 @@ __test__ = {
'localflavor_ch_tests': localflavor_ch_tests,
'localflavor_cl_tests': localflavor_cl_tests,
'localflavor_de_tests': localflavor_de_tests,
+ 'localflavor_es_tests': localflavor_es_tests,
'localflavor_fi_tests': localflavor_fi_tests,
'localflavor_fr_tests': localflavor_fr_tests,
'localflavor_generic_tests': localflavor_generic_tests,
diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py
index 1c3e873963..cb1d084631 100644
--- a/tests/regressiontests/forms/widgets.py
+++ b/tests/regressiontests/forms/widgets.py
@@ -276,6 +276,12 @@ u'<input type="checkbox" name="greeting" />'
>>> w.render('greeting', None)
u'<input type="checkbox" name="greeting" />'
+The CheckboxInput widget will return False if the key is not found in the data
+dictionary (because HTML form submission doesn't send any result for unchecked
+checkboxes).
+>>> w.value_from_datadict({}, {}, 'testing')
+False
+
# Select Widget ###############################################################
>>> w = Select()
@@ -845,4 +851,21 @@ included on both widgets.
>>> w = SplitDateTimeWidget(attrs={'class': 'pretty'})
>>> w.render('date', datetime.datetime(2006, 1, 10, 7, 30))
u'<input type="text" class="pretty" value="2006-01-10" name="date_0" /><input type="text" class="pretty" value="07:30:00" name="date_1" />'
+
+# DateTimeInput ###############################################################
+
+>>> w = DateTimeInput()
+>>> w.render('date', None)
+u'<input type="text" name="date" />'
+>>> d = datetime.datetime(2007, 9, 17, 12, 51, 34, 482548)
+>>> print d
+2007-09-17 12:51:34.482548
+
+The microseconds are trimmed on display, by default.
+>>> w.render('date', d)
+u'<input type="text" name="date" value="2007-09-17 12:51:34" />'
+>>> w.render('date', datetime.datetime(2007, 9, 17, 12, 51, 34))
+u'<input type="text" name="date" value="2007-09-17 12:51:34" />'
+>>> w.render('date', datetime.datetime(2007, 9, 17, 12, 51))
+u'<input type="text" name="date" value="2007-09-17 12:51:00" />'
"""
diff --git a/tests/regressiontests/i18n/misc.py b/tests/regressiontests/i18n/misc.py
new file mode 100644
index 0000000000..fa22fd05d3
--- /dev/null
+++ b/tests/regressiontests/i18n/misc.py
@@ -0,0 +1,57 @@
+tests = """
+>>> from django.utils.translation.trans_real import parse_accept_lang_header
+>>> p = parse_accept_lang_header
+
+Good headers.
+>>> p('de')
+[('de', 1.0)]
+>>> p('en-AU')
+[('en-AU', 1.0)]
+>>> p('*;q=1.00')
+[('*', 1.0)]
+>>> p('en-AU;q=0.123')
+[('en-AU', 0.123)]
+>>> p('en-au;q=0.1')
+[('en-au', 0.10000000000000001)]
+>>> p('en-au;q=1.0')
+[('en-au', 1.0)]
+>>> p('da, en-gb;q=0.25, en;q=0.5')
+[('da', 1.0), ('en', 0.5), ('en-gb', 0.25)]
+>>> p('en-au-xx')
+[('en-au-xx', 1.0)]
+>>> p('de,en-au;q=0.75,en-us;q=0.5,en;q=0.25,es;q=0.125,fa;q=0.125')
+[('de', 1.0), ('en-au', 0.75), ('en-us', 0.5), ('en', 0.25), ('es', 0.125), ('fa', 0.125)]
+>>> p('*')
+[('*', 1.0)]
+>>> p('de;q=0.')
+[('de', 1.0)]
+>>> p('')
+[]
+
+Bad headers; should always return [].
+>>> p('en-gb;q=1.0000')
+[]
+>>> p('en;q=0.1234')
+[]
+>>> p('en;q=.2')
+[]
+>>> p('abcdefghi-au')
+[]
+>>> p('**')
+[]
+>>> p('en,,gb')
+[]
+>>> p('en-au;q=0.1.0')
+[]
+>>> p('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXZ,en')
+[]
+>>> p('da, en-gb;q=0.8, en;q=0.7,#')
+[]
+>>> p('de;q=2.0')
+[]
+>>> p('de;q=0.a')
+[]
+>>> p('')
+[]
+
+"""
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index 99204451e4..0a18e8bea5 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -1,6 +1,7 @@
# coding: utf-8
+import misc
-ur"""
+regressions = ur"""
Format string interpolation should work with *_lazy objects.
>>> from django.utils.translation import ugettext_lazy, activate, deactivate, gettext_lazy
@@ -39,3 +40,8 @@ unicode(string_concat(...)) should not raise a TypeError - #4796
>>> unicode(django.utils.translation.string_concat("dja", "ngo"))
u'django'
"""
+
+__test__ = {
+ 'regressions': regressions,
+ 'misc': misc.tests,
+}
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 0c851d5f78..60f7d54145 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -13,7 +13,7 @@ from datetime import datetime, timedelta
from django import template
from django.template import loader
from django.template.loaders import app_directories, filesystem
-from django.utils.translation import activate, deactivate, install, ugettext as _
+from django.utils.translation import activate, deactivate, ugettext as _
from django.utils.tzinfo import LocalTimezone
from unicode import unicode_tests
@@ -341,7 +341,10 @@ class Templates(unittest.TestCase):
'firstof03': ('{% firstof a b c %}', {'a':0,'b':2,'c':0}, '2'),
'firstof04': ('{% firstof a b c %}', {'a':0,'b':0,'c':3}, '3'),
'firstof05': ('{% firstof a b c %}', {'a':1,'b':2,'c':3}, '1'),
- 'firstof06': ('{% firstof %}', {}, template.TemplateSyntaxError),
+ 'firstof06': ('{% firstof a b c %}', {'b':0,'c':3}, '3'),
+ 'firstof07': ('{% firstof a b "c" %}', {'a':0}, 'c'),
+ 'firstof08': ('{% firstof a b "c and d" %}', {'a':0,'b':0}, 'c and d'),
+ 'firstof09': ('{% firstof %}', {}, template.TemplateSyntaxError),
### FOR TAG ###############################################################
'for-tag01': ("{% for val in values %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "123"),
@@ -802,6 +805,20 @@ class Templates(unittest.TestCase):
'url-fail01' : ('{% url %}', {}, template.TemplateSyntaxError),
'url-fail02' : ('{% url no_such_view %}', {}, ''),
'url-fail03' : ('{% url regressiontests.templates.views.client no_such_param="value" %}', {}, ''),
+
+ ### CACHE TAG ######################################################
+ 'cache01' : ('{% load cache %}{% cache -1 test %}cache01{% endcache %}', {}, 'cache01'),
+ 'cache02' : ('{% load cache %}{% cache -1 test %}cache02{% endcache %}', {}, 'cache02'),
+ 'cache03' : ('{% load cache %}{% cache 2 test %}cache03{% endcache %}', {}, 'cache03'),
+ 'cache04' : ('{% load cache %}{% cache 2 test %}cache04{% endcache %}', {}, 'cache03'),
+ 'cache05' : ('{% load cache %}{% cache 2 test foo %}cache05{% endcache %}', {'foo': 1}, 'cache05'),
+ 'cache06' : ('{% load cache %}{% cache 2 test foo %}cache06{% endcache %}', {'foo': 2}, 'cache06'),
+ 'cache07' : ('{% load cache %}{% cache 2 test foo %}cache06{% endcache %}', {'foo': 1}, 'cache05'),
+
+ # Raise exception if we dont have at least 2 args, first one integer.
+ 'cache08' : ('{% load cache %}{% cache %}{% endcache %}', {}, template.TemplateSyntaxError),
+ 'cache09' : ('{% load cache %}{% cache 1 %}{% endcache %}', {}, template.TemplateSyntaxError),
+ 'cache10' : ('{% load cache %}{% cache foo bar %}{% endcache %}', {}, template.TemplateSyntaxError),
}
# Register our custom template loader.
@@ -827,8 +844,6 @@ class Templates(unittest.TestCase):
expected_invalid_str = 'INVALID'
for name, vals in tests:
- install()
-
if isinstance(vals[2], tuple):
normal_string_result = vals[2][0]
invalid_string_result = vals[2][1]
diff --git a/tests/regressiontests/text/tests.py b/tests/regressiontests/text/tests.py
index 0fd22b58b0..962a30ef19 100644
--- a/tests/regressiontests/text/tests.py
+++ b/tests/regressiontests/text/tests.py
@@ -20,8 +20,12 @@ friends'
>>> from django.utils.http import urlquote, urlquote_plus
>>> urlquote(u'Paris & Orl\xe9ans')
u'Paris%20%26%20Orl%C3%A9ans'
+>>> urlquote(u'Paris & Orl\xe9ans', safe="&")
+u'Paris%20&%20Orl%C3%A9ans'
>>> urlquote_plus(u'Paris & Orl\xe9ans')
u'Paris+%26+Orl%C3%A9ans'
+>>> urlquote_plus(u'Paris & Orl\xe9ans', safe="&")
+u'Paris+&+Orl%C3%A9ans'
### iri_to_uri ###########################################################
>>> from django.utils.encoding import iri_to_uri
diff --git a/tests/regressiontests/utils/tests.py b/tests/regressiontests/utils/tests.py
index fe0b226adc..eb3a722888 100644
--- a/tests/regressiontests/utils/tests.py
+++ b/tests/regressiontests/utils/tests.py
@@ -4,7 +4,7 @@ Tests for django.utils.
from unittest import TestCase
-from django.utils import html
+from django.utils import html, checksums
from timesince import timesince_tests
@@ -116,6 +116,32 @@ class TestUtilsHtml(TestCase):
for value, output in items:
self.check_output(f, value, output)
+class TestUtilsChecksums(TestCase):
+
+ def check_output(self, function, value, output=None):
+ """
+ Check that function(value) equals output. If output is None,
+ check that function(value) equals value.
+ """
+ if output is None:
+ output = value
+ self.assertEqual(function(value), output)
+
+ def test_luhn(self):
+ f = checksums.luhn
+ items = (
+ (4111111111111111, True), ('4111111111111111', True),
+ (4222222222222, True), (378734493671000, True),
+ (5424000000000015, True), (5555555555554444, True),
+ (1008, True), ('0000001008', True), ('000000001008', True),
+ (4012888888881881, True), (1234567890123456789012345678909, True),
+ (4111111111211111, False), (42222222222224, False),
+ (100, False), ('100', False), ('0000100', False),
+ ('abc', False), (None, False), (object(), False),
+ )
+ for value, output in items:
+ self.check_output(f, value, output)
+
__test__ = {
'timesince_tests': timesince_tests,
}
diff --git a/tests/runtests.py b/tests/runtests.py
index 9009bf6606..99cc568e6f 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -93,6 +93,7 @@ def django_tests(verbosity, interactive, test_labels):
old_root_urlconf = settings.ROOT_URLCONF
old_template_dirs = settings.TEMPLATE_DIRS
old_use_i18n = settings.USE_I18N
+ old_language_code = settings.LANGUAGE_CODE
old_middleware_classes = settings.MIDDLEWARE_CLASSES
# Redirect some settings for the duration of these tests.
@@ -100,6 +101,7 @@ def django_tests(verbosity, interactive, test_labels):
settings.ROOT_URLCONF = 'urls'
settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), TEST_TEMPLATE_DIR),)
settings.USE_I18N = True
+ settings.LANGUAGE_CODE = 'en'
settings.MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -152,6 +154,7 @@ def django_tests(verbosity, interactive, test_labels):
settings.ROOT_URLCONF = old_root_urlconf
settings.TEMPLATE_DIRS = old_template_dirs
settings.USE_I18N = old_use_i18n
+ settings.LANGUAGE_CODE = old_language_code
settings.MIDDLEWARE_CLASSES = old_middleware_classes
if __name__ == "__main__":