From 4660ce5a6930e07899ed083801845ee4c44c09df Mon Sep 17 00:00:00 2001 From: CHI Cheng Date: Wed, 2 May 2018 23:20:04 +1000 Subject: Fixed #29375 -- Removed empty action attribute on HTML forms. --- .../templates/forms_tests/article_form.html | 2 +- tests/forms_tests/tests/test_forms.py | 34 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'tests/forms_tests') diff --git a/tests/forms_tests/templates/forms_tests/article_form.html b/tests/forms_tests/templates/forms_tests/article_form.html index 8ab7a85bb9..3edd8713de 100644 --- a/tests/forms_tests/templates/forms_tests/article_form.html +++ b/tests/forms_tests/templates/forms_tests/article_form.html @@ -1,6 +1,6 @@ -
{% csrf_token %} + {% csrf_token %} {{ form.as_p }}
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index f603a95a17..914f2b5345 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2482,13 +2482,13 @@ Password: return 'VALID: %r' % sorted(form.cleaned_data.items()) t = Template( - '
\n' + '\n' '\n{{ form }}\n
\n\n
' ) return t.render(Context({'form': form})) # Case 1: GET (an empty form, with no errors).) - self.assertHTMLEqual(my_function('GET', {}), """
+ self.assertHTMLEqual(my_function('GET', {}), """ @@ -2499,7 +2499,7 @@ Password: # Case 2: POST with erroneous data (a redisplayed form, with errors).) self.assertHTMLEqual( my_function('POST', {'username': 'this-is-a-long-username', 'password1': 'foo', 'password2': 'bar'}), - """ + """
Username:
Password1:
  • Please make sure your passwords match.
Username:
    @@ -2535,13 +2535,13 @@ Password: # fields. Note, however, that this flexibility comes with the responsibility of # displaying all the errors, including any that might not be associated with a # particular field. - t = Template(''' + t = Template(''' {{ form.username.errors.as_ul }}

    {{ form.password1.errors.as_ul }}

    {{ form.password2.errors.as_ul }}

    ''') - self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """
    + self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """

    @@ -2549,7 +2549,7 @@ Password:
    """) self.assertHTMLEqual( t.render(Context({'form': UserRegistration({'username': 'django'}, auto_id=False)})), - """
    + """

    • This field is required.

    @@ -2563,13 +2563,13 @@ Password: # a field by using the 'label' argument to a Field class. If you don't specify # 'label', Django will use the field name with underscores converted to spaces, # and the initial letter capitalized. - t = Template(''' + t = Template('''

    ''') - self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """
    + self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """

    @@ -2580,19 +2580,19 @@ Password: # wrapped around it, but *only* if the given field has an "id" attribute. # Recall from above that passing the "auto_id" argument to a Form gives each # field an "id" attribute. - t = Template(''' + t = Template('''

    {{ form.username.label_tag }} {{ form.username }}

    {{ form.password1.label_tag }} {{ form.password1 }}

    {{ form.password2.label_tag }} {{ form.password2 }}

    ''') - self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """
    + self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id=False)})), """

    Username:

    Password1:

    Password2:

    """) - self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id='id_%s')})), """
    + self.assertHTMLEqual(t.render(Context({'form': UserRegistration(auto_id='id_%s')})), """

    @@ -2604,7 +2604,7 @@ Password: # User form.[field].help_text to output a field's help text. If the given field # does not have help text, nothing will be output. - t = Template(''' + t = Template('''

    {{ form.username.label_tag }} {{ form.username }}
    {{ form.username.help_text }}

    {{ form.password1.label_tag }} {{ form.password1 }}

    {{ form.password2.label_tag }} {{ form.password2 }}

    @@ -2612,7 +2612,7 @@ Password:
    ''') self.assertHTMLEqual( t.render(Context({'form': UserRegistration(auto_id=False)})), - """
    + """

    Username:
    Good luck picking a username that doesn't already exist.

    Password1:

    @@ -2629,7 +2629,7 @@ Good luck picking a username that doesn't already exist.

    # the errors caused by Form.clean() -- use {{ form.non_field_errors }} in the # template. If used on its own, it is displayed as a
      (or an empty string, if # the list of errors is empty). You can also use it in {% if %} statements. - t = Template(''' + t = Template(''' {{ form.username.errors.as_ul }}

      {{ form.password1.errors.as_ul }}

      {{ form.password2.errors.as_ul }}

      @@ -2639,14 +2639,14 @@ Good luck picking a username that doesn't already exist.

      t.render(Context({ 'form': UserRegistration({'username': 'django', 'password1': 'foo', 'password2': 'bar'}, auto_id=False) })), - """ + """

      """ ) - t = Template('''
      + t = Template(''' {{ form.non_field_errors }} {{ form.username.errors.as_ul }}

      {{ form.password1.errors.as_ul }}

      @@ -2657,7 +2657,7 @@ Good luck picking a username that doesn't already exist.

      t.render(Context({ 'form': UserRegistration({'username': 'django', 'password1': 'foo', 'password2': 'bar'}, auto_id=False) })), - """ + """
      • Please make sure your passwords match.

      -- cgit v1.3