From a97abcffc27c5026041afccb1d76f7e4e4b1df69 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 28 Nov 2007 21:51:17 +0000 Subject: queryset-refactor: Merged from trunk up to [6724]. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6726 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/widgets.py | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/regressiontests/forms/widgets.py') diff --git a/tests/regressiontests/forms/widgets.py b/tests/regressiontests/forms/widgets.py index cb1d084631..ea8cf135aa 100644 --- a/tests/regressiontests/forms/widgets.py +++ b/tests/regressiontests/forms/widgets.py @@ -2,6 +2,7 @@ tests = r""" >>> from django.newforms import * >>> from django.newforms.widgets import RadioFieldRenderer +>>> from django.utils.safestring import mark_safe >>> import datetime >>> import time >>> import re @@ -205,6 +206,8 @@ u'' u'' >>> w.render('msg', 'some "quoted" & ampersanded value') u'' +>>> w.render('msg', mark_safe('pre "quoted" value')) +u'' >>> w.render('msg', 'value', attrs={'class': 'pretty', 'rows': 20}) u'' @@ -375,6 +378,17 @@ If 'choices' is passed to both the constructor and render(), then they'll both b +# Choices are escaped correctly +>>> print w.render('escape', None, choices=(('bad', 'you & me'), ('good', mark_safe('you > me')))) + + +# Unicode choices are correctly rendered as HTML >>> w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) u'' @@ -538,6 +552,17 @@ If 'choices' is passed to both the constructor and render(), then they'll both b +# Choices are escaped correctly +>>> print w.render('escape', None, choices=(('bad', 'you & me'), ('good', mark_safe('you > me')))) + + +# Unicode choices are correctly rendered as HTML >>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) u'' @@ -663,6 +688,16 @@ You can create your own custom renderers for RadioSelect to use.
+Or you can use custom RadioSelect fields that use your custom renderer. +>>> class CustomRadioSelect(RadioSelect): +... renderer = MyRenderer +>>> w = CustomRadioSelect() +>>> print w.render('beatle', 'G', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) +
+
+
+ + A RadioFieldRenderer object also allows index access to individual RadioInput objects. >>> w = RadioSelect() @@ -682,6 +717,14 @@ Traceback (most recent call last): ... IndexError: list index out of range +# Choices are escaped correctly +>>> w = RadioSelect() +>>> print w.render('escape', None, choices=(('bad', 'you & me'), ('good', mark_safe('you > me')))) + + # Unicode choices are correctly rendered as HTML >>> w = RadioSelect() >>> unicode(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')])) @@ -811,6 +854,17 @@ If 'choices' is passed to both the constructor and render(), then they'll both b
  • +# Choices are escaped correctly +>>> print w.render('escape', None, choices=(('bad', 'you & me'), ('good', mark_safe('you > me')))) + + +# Unicode choices are correctly rendered as HTML >>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) u'' -- cgit v1.3