test.Response.resolver_match

resolver_match

An instance of ResolverMatch for the response. You can use the func attribute, for example, to verify the view that served the response:

# my_view here is a function based view
self.assertEqual(response.resolver_match.func, my_view)

# class-based views need to be compared by name, as the functions
# generated by as_view() won't be equal
self.assertEqual(response.resolver_match.func.__name__, MyView.as_view().__name__)

If the given URL is not found, accessing this attribute will raise a Resolver404 exception.

doc_Django
2016-10-09 18:40:00
Comments
Leave a Comment

Please login to continue.