From 6dd4e6d046b9c4b60efb9b85f974b2acd049d791 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Thu, 16 Nov 2006 06:45:29 +0000 Subject: newforms: Fixed #3008 -- Widgets now support strings containing utf-8 characters. Thanks for reporting, Nebojša Đorđević MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@4076 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/tests.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'tests/regressiontests/forms/tests.py') 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'' +# 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'' + You can also pass 'attrs' to the constructor: >>> w = TextInput(attrs={'class': 'fun'}) >>> w.render('email', '') @@ -55,6 +61,9 @@ u'' >>> w.render('email', '', attrs={'class': 'special'}) u'' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'' + # HiddenInput Widget ############################################################ >>> w = HiddenInput() @@ -81,6 +90,14 @@ u'' >>> w.render('email', '', attrs={'class': 'special'}) u'' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'' + +'attrs' passed to render() get precedence over those passed to the constructor: +>>> w = HiddenInput(attrs={'class': 'pretty'}) +>>> w.render('email', '', attrs={'class': 'special'}) +u'' + # FileInput Widget ############################################################ >>> w = FileInput() @@ -102,10 +119,8 @@ u'' >>> w.render('email', 'foo@example.com') u'' -'attrs' passed to render() get precedence over those passed to the constructor: ->>> w = HiddenInput(attrs={'class': 'pretty'}) ->>> w.render('email', '', attrs={'class': 'special'}) -u'' +>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'' # Textarea Widget ############################################################# @@ -133,6 +148,9 @@ u'' >>> w.render('msg', '', attrs={'class': 'special'}) u'' +>>> w.render('msg', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) +u'' + # CheckboxInput Widget ######################################################## >>> w = CheckboxInput() @@ -236,6 +254,9 @@ If 'choices' is passed to both the constructor and render(), then they'll both b +>>> w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) +u'' + # SelectMultiple Widget ####################################################### >>> w = SelectMultiple() @@ -340,6 +361,9 @@ If 'choices' is passed to both the constructor and render(), then they'll both b +>>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) +u'' + # RadioSelect Widget ########################################################## >>> w = RadioSelect() -- cgit v1.3