0
votes

I have a form with name and email, want to test it. I am trying to test the HTML content after the post, some thing as below.

I simulated the post data as follows.

response = self.c.post('/app/url/', {'name': 'xxx', 'email': '[email protected]')

After the user post the data, I want to verify the name and email from the HTML content as follows.

with self.assertHTML(response, 'input[name="xxx"]') as (elem,):    
self.assertEqual(elem.value, 'xxx')

While run the tests I am getting the error:

object has no attribute 'assertHTML'

Can any one provide suggestions how to resolve this error, if any package needs to be installed please suggest what to install and how to install.

1

1 Answers

1
votes

In the django docs I can neither find assertHTML as method nor does a context manager like this exist.

The docs you are refering to are for an additional package https://pypi.python.org/pypi/django-with-asserts. If you want to use it, you need to install it and import it. Have you done that?

If you had give the full code, it would have been much easier and people would not need to guess, what you have imported.