summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-05 16:17:35 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-05 16:17:35 +0000
commita9b2c0686d98f78ca365a04057699a44f7711914 (patch)
tree451caf3f856bb51e72c2b88d5fcefbedbadf7b01 /tests
parent5bcf13b607ea92c34d13cbb52f70c1e6b76ce5cd (diff)
boulder-oracle-sprint: Merged to [4934].
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4935 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/defaultfilters/tests.py19
-rw-r--r--tests/regressiontests/forms/localflavor.py63
-rw-r--r--tests/regressiontests/forms/regressions.py16
-rw-r--r--tests/regressiontests/forms/tests.py4
4 files changed, 79 insertions, 23 deletions
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index db3f7fab2a..4a2e9432b0 100644
--- a/tests/regressiontests/defaultfilters/tests.py
+++ b/tests/regressiontests/defaultfilters/tests.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
r"""
>>> floatformat(7.7)
'7.7'
@@ -87,19 +89,19 @@ u'\xeb'
>>> truncatewords('A sentence with a few words in it', 'not a number')
'A sentence with a few words in it'
->>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0)
+>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0)
''
-
->>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2)
+
+>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2)
'<p>one <a href="#">two ...</a></p>'
-
->>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4)
+
+>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4)
'<p>one <a href="#">two - three <br>four ...</a></p>'
->>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5)
+>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5)
'<p>one <a href="#">two - three <br>four</a> five</p>'
->>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100)
+>>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100)
'<p>one <a href="#">two - three <br>four</a> five</p>'
>>> upper('Mixed case input')
@@ -166,6 +168,9 @@ u'\xcb'
>>> escape('<some html & special characters > here')
'&lt;some html &amp; special characters &gt; here'
+>>> escape(u'<some html & special characters > here ĐÅ€£')
+u'&lt;some html &amp; special characters &gt; here \xc4\x90\xc3\x85\xe2\x82\xac\xc2\xa3'
+
>>> linebreaks('line 1')
'<p>line 1</p>'
diff --git a/tests/regressiontests/forms/localflavor.py b/tests/regressiontests/forms/localflavor.py
index f166a24ef0..e9c027b5c8 100644
--- a/tests/regressiontests/forms/localflavor.py
+++ b/tests/regressiontests/forms/localflavor.py
@@ -246,6 +246,18 @@ as its choices.
<option value="WY">Wyoming</option>
</select>
+# USSocialSecurityNumberField #################################################
+>>> from django.contrib.localflavor.usa.forms import USSocialSecurityNumberField
+>>> f = USSocialSecurityNumberField()
+>>> f.clean('987-65-4330')
+u'987-65-4330'
+>>> f.clean('987654330')
+u'987-65-4330'
+>>> f.clean('078-05-1120')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.']
+
# UKPostcodeField #############################################################
UKPostcodeField validates that the data is a valid UK postcode.
@@ -734,23 +746,23 @@ u'12345-123'
>>> f.clean('12345_123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('1234-123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('abcde-abc')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('-123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('')
Traceback (most recent call last):
...
@@ -768,23 +780,23 @@ u''
>>> f.clean('-123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('abcde-abc')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('1234-123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345_123')
Traceback (most recent call last):
...
-ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.']
+ValidationError: [u'Enter a zip code in the format XXXXX-XXX.']
>>> f.clean('12345-123')
u'12345-123'
@@ -839,4 +851,35 @@ u'41-3562-3464'
>>> w = BRStateSelect()
>>> w.render('states', 'PR')
u'<select name="states">\n<option value="AC">Acre</option>\n<option value="AL">Alagoas</option>\n<option value="AP">Amap\xe1</option>\n<option value="AM">Amazonas</option>\n<option value="BA">Bahia</option>\n<option value="CE">Cear\xe1</option>\n<option value="DF">Distrito Federal</option>\n<option value="ES">Esp\xedrito Santo</option>\n<option value="GO">Goi\xe1s</option>\n<option value="MA">Maranh\xe3o</option>\n<option value="MT">Mato Grosso</option>\n<option value="MS">Mato Grosso do Sul</option>\n<option value="MG">Minas Gerais</option>\n<option value="PA">Par\xe1</option>\n<option value="PB">Para\xedba</option>\n<option value="PR" selected="selected">Paran\xe1</option>\n<option value="PE">Pernambuco</option>\n<option value="PI">Piau\xed</option>\n<option value="RJ">Rio de Janeiro</option>\n<option value="RN">Rio Grande do Norte</option>\n<option value="RS">Rio Grande do Sul</option>\n<option value="RO">Rond\xf4nia</option>\n<option value="RR">Roraima</option>\n<option value="SC">Santa Catarina</option>\n<option value="SP">S\xe3o Paulo</option>\n<option value="SE">Sergipe</option>\n<option value="TO">Tocantins</option>\n</select>'
+
+# DEZipCodeField ##############################################################
+
+>>> from django.contrib.localflavor.de.forms import DEZipCodeField
+>>> f = DEZipCodeField()
+>>> f.clean('99423')
+u'99423'
+>>> f.clean(' 99423')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a zip code in the format XXXXX.']
+
+# DEStateSelect #############################################################
+
+>>> from django.contrib.localflavor.de.forms import DEStateSelect
+>>> w = DEStateSelect()
+>>> w.render('states', 'TH')
+u'<select name="states">\n<option value="BW">Baden-Wuerttemberg</option>\n<option value="BY">Bavaria</option>\n<option value="BE">Berlin</option>\n<option value="BB">Brandenburg</option>\n<option value="HB">Bremen</option>\n<option value="HH">Hamburg</option>\n<option value="HE">Hessen</option>\n<option value="MV">Mecklenburg-Western Pomerania</option>\n<option value="NI">Lower Saxony</option>\n<option value="NW">North Rhine-Westphalia</option>\n<option value="RP">Rhineland-Palatinate</option>\n<option value="SL">Saarland</option>\n<option value="SN">Saxony</option>\n<option value="ST">Saxony-Anhalt</option>\n<option value="SH">Schleswig-Holstein</option>\n<option value="TH" selected="selected">Thuringia</option>\n</select>'
+
+# DEIdentityCardNumberField #################################################
+
+>>> from django.contrib.localflavor.de.forms import DEIdentityCardNumberField
+>>> f = DEIdentityCardNumberField()
+>>> f.clean('7549313035D-6004103-0903042-0')
+u'7549313035D-6004103-0903042-0'
+>>> f.clean('9786324830D 6104243 0910271 2')
+u'9786324830D-6104243-0910271-2'
+>>> f.clean('0434657485D-6407276-0508137-9')
+Traceback (most recent call last):
+...
+ValidationError: [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format']
"""
diff --git a/tests/regressiontests/forms/regressions.py b/tests/regressiontests/forms/regressions.py
index 02b38ec58d..5daabc03af 100644
--- a/tests/regressiontests/forms/regressions.py
+++ b/tests/regressiontests/forms/regressions.py
@@ -11,11 +11,11 @@ It should be possible to re-use attribute dictionaries (#3810)
>>> TestForm(auto_id=False).as_p()
u'<p>F1: <input type="text" class="special" name="f1" maxlength="10" /></p>\n<p>F2: <input type="text" class="special" name="f2" /></p>'
-#######################
-# Tests for form i18n #
-#######################
+#######################
+# Tests for form i18n #
+#######################
There were some problems with form translations in #3600
-
+
>>> from django.utils.translation import gettext_lazy, activate, deactivate
>>> class SomeForm(Form):
... username = CharField(max_length=10, label=gettext_lazy('Username'))
@@ -26,4 +26,12 @@ There were some problems with form translations in #3600
>>> print f.as_p()
<p><label for="id_username">Benutzername:</label> <input id="id_username" type="text" name="username" maxlength="10" /></p>
>>> deactivate()
+
+Unicode decoding problems...
+>>> GENDERS = (('0', u'En tied\xe4'), ('1', u'Mies'), ('2', u'Nainen'))
+>>> class SomeForm(Form):
+... somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect())
+>>> f = SomeForm()
+>>> f.as_p()
+u'<p><label for="id_somechoice_0">Somechoice:</label> <ul>\n<li><label><input type="radio" id="id_somechoice_0" value="0" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="1" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="2" name="somechoice" /> Nainen</label></li>\n</ul></p>'
"""
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py
index 8ecc9f0205..e78a4d0ec3 100644
--- a/tests/regressiontests/forms/tests.py
+++ b/tests/regressiontests/forms/tests.py
@@ -1455,7 +1455,7 @@ u''
>>> f.clean('http://www.google.com') # This will fail if there's no Internet connection
u'http://www.google.com'
-EmailField also access min_length and max_length parameters, for convenience.
+URLField also access min_length and max_length parameters, for convenience.
>>> f = URLField(min_length=15, max_length=20)
>>> f.clean('http://f.com')
Traceback (most recent call last):
@@ -3276,7 +3276,7 @@ True
#################################
# smart_unicode tests
->>> from django.newforms.util import smart_unicode
+>>> from django.utils.encoding import smart_unicode
>>> class Test:
... def __str__(self):
... return 'ŠĐĆŽćžšđ'