'Test that 404.html and 500.html templates are picked by their respective
handler.'

def test_custom_templates(self):

    setup_test_template_loader({u'404.html': u'This    is    a    test    template    for    a    404    error.', u'500.html': u'This    is    a    test    template    for    a    500    error.'})
    try:
        for (code, url) in ((404, u'/views/non_existing_url/'), (500, u'/views/server_error/')):
            response = self.client.get(url)
            self.assertContains(response, (u'test    template    for    a    %d    error' % code), status_code=code)
    finally:
        restore_template_loaders()
