assertContains is not for test random strings. It's for testing the response from view -- specifically that the response contains a certain bit of text. If you're not using a TestClient and testing against the response from one of your views, you can't use it.