diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-12 20:10:30 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-09-12 20:10:30 +0000 |
| commit | f7f2c7251a91499e901a241e0bfd120485d025a2 (patch) | |
| tree | 3b48c7f2d61a8fb24dbcd2a018de54b6b0ef8f94 /tests/regressiontests | |
| parent | 24f4a4b26f1fe2be130b4f1117e5189b9f438e78 (diff) | |
[1.2.X] Migrated i18n and field_defaults doctests. Thanks to Alex Gaynor.
Backport of r13779 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@13796 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/i18n/models.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/i18n/tests.py | 21 |
2 files changed, 18 insertions, 9 deletions
diff --git a/tests/regressiontests/i18n/models.py b/tests/regressiontests/i18n/models.py index 8b142b36bc..75cd996f83 100644 --- a/tests/regressiontests/i18n/models.py +++ b/tests/regressiontests/i18n/models.py @@ -10,9 +10,3 @@ class Company(models.Model): date_added = models.DateTimeField(default=datetime(1799,1,31,23,59,59,0)) cents_payed = models.DecimalField(max_digits=4, decimal_places=2) products_delivered = models.IntegerField() - -__test__ = {'API_TESTS': ''' ->>> tm = TestModel() ->>> tm.save() -''' -} diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index 8c1c7f3d8b..7e2e9f8228 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -5,14 +5,17 @@ import os import sys import pickle -from django.template import Template, Context from django.conf import settings +from django.template import Template, Context +from django.test import TestCase from django.utils.formats import get_format, date_format, time_format, localize, localize_input from django.utils.numberformat import format as nformat -from django.test import TestCase +from django.utils.safestring import mark_safe, SafeString, SafeUnicode from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale + from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm +from models import Company, TestModel class TranslationTests(TestCase): @@ -59,7 +62,6 @@ class TranslationTests(TestCase): """ Translating a string requiring no auto-escaping shouldn't change the "safe" status. """ - from django.utils.safestring import mark_safe, SafeString, SafeUnicode s = mark_safe('Password') self.assertEqual(SafeString, type(s)) activate('de') @@ -620,3 +622,16 @@ class DjangoFallbackResolutionOrderI18NTests(ResolutionOrderI18NTests): def test_django_fallback(self): self.assertUgettext('Date/time', 'Datum/Zeit') + + +class TestModels(TestCase): + def test_lazy(self): + tm = TestModel() + tm.save() + + def test_safestr(self): + c = Company(cents_payed=12, products_delivered=1) + c.name = SafeUnicode(u'Iñtërnâtiônàlizætiøn1') + c.save() + c.name = SafeString(u'Iñtërnâtiônàlizætiøn1'.encode('utf-8')) + c.save() |
