[Answered ]-Django AssertTemplateUsed test fails since Upgrade to Django 1.8

2👍

The error seems quite clear: you can only use that assertion on responses fetched via the test client. You’re not using that, you’re canning the view directly.

You should use the client anyway: it would simplify your test considerably. It would just become:

def test_year_view_uses_right_template(self):
    self.client.login('cj123', 'xxx')
    response = self.client.get('/year_view/all')
    self.assertTemplateUsed(response, 'year_view.html')

Leave a comment