From dd49269c7db008b2567f50cb03c4d3d9b321daa1 Mon Sep 17 00:00:00 2001 From: Arthur Koziel Date: Mon, 13 Sep 2010 00:04:27 +0000 Subject: [soc2010/app-loading] merged trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/forms.py | 52 ++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'tests/regressiontests/forms/forms.py') diff --git a/tests/regressiontests/forms/forms.py b/tests/regressiontests/forms/forms.py index 58051fd133..91594139f2 100644 --- a/tests/regressiontests/forms/forms.py +++ b/tests/regressiontests/forms/forms.py @@ -522,6 +522,18 @@ tags. +DateTimeField rendered as_hidden() is special too + +>>> class MessageForm(Form): +... when = SplitDateTimeField() +>>> f = MessageForm({'when_0': '1992-01-01', 'when_1': '01:01'}) +>>> print f.is_valid() +True +>>> print f['when'] + +>>> print f['when'].as_hidden() + + MultipleChoiceField can also be used with the CheckboxSelectMultiple widget. >>> class SongForm(Form): ... name = CharField() @@ -705,13 +717,13 @@ Form.clean() is required to return a dictionary of all clean data. >>> print f.as_table() Username: -Password1: -Password2: +Password1: +Password2: >>> print f.as_ul()
  • Username:
  • -
  • Password1:
  • -
  • Password2:
  • +
  • Password1:
  • +
  • Password2:
  • >>> f = UserRegistration({'username': 'adrian', 'password1': 'foo', 'password2': 'foo'}, auto_id=False) >>> f.errors {} @@ -1258,20 +1270,20 @@ to a Field class. This help text is displayed when a Form is rendered. ... password = CharField(widget=PasswordInput, help_text='Choose wisely.') >>> p = UserRegistration(auto_id=False) >>> print p.as_ul() -
  • Username: e.g., user@example.com
  • -
  • Password: Choose wisely.
  • +
  • Username: e.g., user@example.com
  • +
  • Password: Choose wisely.
  • >>> print p.as_p() -

    Username: e.g., user@example.com

    -

    Password: Choose wisely.

    +

    Username: e.g., user@example.com

    +

    Password: Choose wisely.

    >>> print p.as_table() -Username:
    e.g., user@example.com -Password:
    Choose wisely. +Username:
    e.g., user@example.com +Password:
    Choose wisely. The help text is displayed whether or not data is provided for the form. >>> p = UserRegistration({'username': u'foo'}, auto_id=False) >>> print p.as_ul() -
  • Username: e.g., user@example.com
  • -
  • Password: Choose wisely.
  • +
  • Username: e.g., user@example.com
  • +
  • Password: Choose wisely.
  • help_text is not displayed for hidden fields. It can be used for documentation purposes, though. @@ -1281,7 +1293,7 @@ purposes, though. ... next = CharField(widget=HiddenInput, initial='/', help_text='Redirect destination') >>> p = UserRegistration(auto_id=False) >>> print p.as_ul() -
  • Username: e.g., user@example.com
  • +
  • Username: e.g., user@example.com
  • Password:
  • Help text can include arbitrary Unicode characters. @@ -1289,7 +1301,7 @@ Help text can include arbitrary Unicode characters. ... username = CharField(max_length=10, help_text='ŠĐĆŽćžšđ') >>> p = UserRegistration(auto_id=False) >>> p.as_ul() -u'
  • Username: \u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111
  • ' +u'
  • Username: \u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111
  • ' # Subclassing forms ########################################################### @@ -1589,8 +1601,8 @@ Case 2: POST with erroneous data (a redisplayed form, with errors). - - + +
    • Please make sure your passwords match.
    Username:
    • Ensure this value has at most 10 characters (it has 23).
    Password1:
    Password2:
    Password1:
    Password2:
    @@ -1719,8 +1731,8 @@ the list of errors is empty). You can also use it in {% if %} statements. >>> print t.render(Context({'form': UserRegistration({'username': 'django', 'password1': 'foo', 'password2': 'bar'}, auto_id=False)}))

    -

    -

    +

    +

    >>> t = Template('''
    @@ -1734,8 +1746,8 @@ the list of errors is empty). You can also use it in {% if %} statements.

    -

    -

    +

    +

    -- cgit v1.3