First, thanks for the suggestion.
I just tried that, didn't work.
Here is the test file I used:
from django.test import TestCase
class HTMLTestCase(TestCase):
def test_input_in_fieldset(self):
fieldset = """
<fieldset class="form-group">
<input name="login">
<input autofocus="" class="form-control" id="id_username"
maxlength="254" name="username" rows="3" type="text" required />
</fieldset>
"""
self.assertInHTML('<input name=login>', fieldset)
self.assertInHTML('<input name="username">', fieldset)
First input is to have a working exemple, second is taken as is from
my view. Not closing the input in assertInHTML give an error `Couldn't
find '<input name="login"' in response`. I assume I would get the same
errors with assertContains(*args, html=True)
I could copy/past the input directly in my test but if the maxlength
or class attribute change, the test will break. Taking the input
directly from the django form will test if the django form is rendered
in the view, not if the view is displaying a suitable form.
>
https://groups.google.com/d/msgid/django-users/CALXYUbmmotLwzjZY6ZZnAqy21xqZN1%3DiE7ah3g5JxFgEw-POZg%40mail.gmail.com.