summaryrefslogtreecommitdiff
path: root/docs/topics/testing/tools.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/topics/testing/tools.txt')
-rw-r--r--docs/topics/testing/tools.txt8
1 files changed, 4 insertions, 4 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 1d8cbfbd72..c6923c6c87 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -541,12 +541,12 @@ Specifically, a ``Response`` object has the following attributes:
You can use the :attr:`~django.urls.ResolverMatch.func` attribute, for
example, to verify the view that served the response::
- # my_view here is a function based view
+ # 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__)
+ # Class-based views need to compare the view_class, as the
+ # functions generated by as_view() won't be equal.
+ self.assertIs(response.resolver_match.func.view_class, MyView)
If the given URL is not found, accessing this attribute will raise a
:exc:`~django.urls.Resolver404` exception.