[Django]-Django testing, assert CSV content is present

5👍

Looking at the stacktrace you added to the question, the stacktrace corresponds to the call to self.assertNotContains(response.content, 'Vipul').

Looking at the docs for SimpleTestCase.assertNotContains(), I notice that the method expects the whole response, not just the content as parameter.

So, changing this line:

self.assertNotContains(response.content, 'Vipul')

to this

self.assertNotContains(response, 'Vipul')

should clear up the error for which you added the stacktrace.


Now, I notice that you also have this line in your question:

I tried different options such as self.assertContains(response,'aakash'), but didn’t get any result.

You will have to be more specific as to what you mean by "didn't get any result" if you want us to be able to help you.

👤Ralf

Leave a comment