Monday, October 28, 2013

Re: What's the difference between assertIn and assertContains?

assertContains performs additional assertion such as the status code of the
request and provides a way to perform comparison based on HTML semantic
instead of character-by-character equality. Under the hood it also handles
streaming and deferred response gracefully.

I suggest you take a look at the documentation for a technical reference and
at the source code for the implementation details.

Simon

Le lundi 28 octobre 2013 20:45:17 UTC-4, Pepsodent Cola a écrit :
    # List word
    def test_VIEW_Index_WORD_List_word(self):
        w = self.create_word()
        url = reverse('navi_polls:index')
        resp = self.client.get(url)
        self.assertEqual(resp.status_code, 200)
        self.assertIn(w.rosword, resp.content) # What's the difference between
                                                               # assertIn and assertContains?
        #self.assertContains(resp, "Test word")
        self.assertContains(resp, w.rosword)


test_VIEW_Index_WORD_List_word (navi_polls.tests.WordTests) ... ok



What's the difference between assertIn and assertContains?
They seem to perform the same kind of test, the only difference I can see is that the syntax differs.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/daa74f88-4822-42f4-9007-ae66bfea2040%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment