I use this sentences to check the letters line1 and line2 appears.
self.assertContains(response,"line1"); self.assertContains(response,"line2");
However I want to check the order of appearance.
I checked in this page, but can't figure out which I should use.
https://docs.djangoproject.com/en/2.2/topics/testing/tools/#django.test.SimpleTestCase.assertContains
Are you saying you want to assert that line 1 appears in the response before line2?
There isn't (probably; I haven't checked but would be quite surprised) a specific command that would assert that.
Instead, use
find()to get the indices of where in the responseline1andline2are found, then compare them.EDIT: But be aware that if the content isn't found,
findwill return-1. A solution could be to first just use yourassertContainsto check thatline1andline2are present, and after that usefind()to verify that one comes before the other.