diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-11-16 06:45:29 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-11-16 06:45:29 +0000 |
| commit | 6dd4e6d046b9c4b60efb9b85f974b2acd049d791 (patch) | |
| tree | 421c89e7f8451a4842189ffbe0fcaacc9cc92d46 /tests/regressiontests/forms | |
| parent | 75516392b8bc93ae80a9faeb58d8d9cb5298be9d (diff) | |
newforms: Fixed #3008 -- Widgets now support strings containing utf-8 characters. Thanks for reporting, Nebojša Đorđević
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4076 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index b02ccb8ee8..c4dd7074a5 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1,4 +1,5 @@ -""" +# -*- coding: utf-8 -*- +r""" >>> from django.newforms import * >>> import datetime >>> import re @@ -17,6 +18,11 @@ u'<input type="text" name="email" value="some "quoted" & ampersand >>> w.render('email', 'test@example.com', attrs={'class': 'fun'}) u'<input type="text" name="email" value="test@example.com" class="fun" />' +# Note that doctest in Python 2.4 (and maybe 2.5?) doesn't support non-ascii +# characters in output, so we're displaying the repr() here. +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'<input type="text" name="email" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" class="fun" />' + You can also pass 'attrs' to the constructor: >>> w = TextInput(attrs={'class': 'fun'}) >>> w.render('email', '') @@ -55,6 +61,9 @@ u'<input type="password" class="fun" value="foo@example.com" name="email" />' >>> w.render('email', '', attrs={'class': 'special'}) u'<input type="password" class="special" name="email" />' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'<input type="password" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" name="email" />' + # HiddenInput Widget ############################################################ >>> w = HiddenInput() @@ -81,6 +90,14 @@ u'<input type="hidden" class="fun" value="foo@example.com" name="email" />' >>> w.render('email', '', attrs={'class': 'special'}) u'<input type="hidden" class="special" name="email" />' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'<input type="hidden" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" name="email" />' + +'attrs' passed to render() get precedence over those passed to the constructor: +>>> w = HiddenInput(attrs={'class': 'pretty'}) +>>> w.render('email', '', attrs={'class': 'special'}) +u'<input type="hidden" class="special" name="email" />' + # FileInput Widget ############################################################ >>> w = FileInput() @@ -102,10 +119,8 @@ u'<input type="file" class="fun" name="email" />' >>> w.render('email', 'foo@example.com') u'<input type="file" class="fun" value="foo@example.com" name="email" />' -'attrs' passed to render() get precedence over those passed to the constructor: ->>> w = HiddenInput(attrs={'class': 'pretty'}) ->>> w.render('email', '', attrs={'class': 'special'}) -u'<input type="hidden" class="special" name="email" />' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'<input type="file" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" name="email" />' # Textarea Widget ############################################################# @@ -133,6 +148,9 @@ u'<textarea class="pretty" name="msg">example</textarea>' >>> w.render('msg', '', attrs={'class': 'special'}) u'<textarea class="special" name="msg"></textarea>' +>>> w.render('msg', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'<textarea class="fun" name="msg">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>' + # CheckboxInput Widget ######################################################## >>> w = CheckboxInput() @@ -236,6 +254,9 @@ If 'choices' is passed to both the constructor and render(), then they'll both b <option value="5">5</option> </select> +>>> w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) +u'<select name="email">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" selected="selected">\u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</option>\n<option value="\u0107\u017e\u0161\u0111">abc\u0107\u017e\u0161\u0111</option>\n</select>' + # SelectMultiple Widget ####################################################### >>> w = SelectMultiple() @@ -340,6 +361,9 @@ If 'choices' is passed to both the constructor and render(), then they'll both b <option value="5">5</option> </select> +>>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) +u'<select multiple="multiple" name="nums">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" selected="selected">\u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</option>\n<option value="\u0107\u017e\u0161\u0111">abc\u0107\u017e\u0161\u0111</option>\n</select>' + # RadioSelect Widget ########################################################## >>> w = RadioSelect() |
