mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Fixed #16087 -- Added ResolverMatch instance to test client response.
Thanks mrmachine for the suggestion.
This commit is contained in:
		| @@ -99,6 +99,29 @@ class ClientTest(TestCase): | ||||
|             self.assertIn(key, response.wsgi_request.environ) | ||||
|             self.assertEqual(response.wsgi_request.environ[key], value) | ||||
|  | ||||
|     def test_response_resolver_match(self): | ||||
|         """ | ||||
|         The response contains a ResolverMatch instance. | ||||
|         """ | ||||
|         response = self.client.get('/header_view/') | ||||
|         self.assertTrue(hasattr(response, 'resolver_match')) | ||||
|  | ||||
|     def test_response_resolver_match_redirect_follow(self): | ||||
|         """ | ||||
|         The response ResolverMatch instance contains the correct | ||||
|         information when following redirects. | ||||
|         """ | ||||
|         response = self.client.get('/redirect_view/', follow=True) | ||||
|         self.assertEqual(response.resolver_match.url_name, 'get_view') | ||||
|  | ||||
|     def test_response_resolver_match_regular_view(self): | ||||
|         """ | ||||
|         The response ResolverMatch instance contains the correct | ||||
|         information when accessing a regular view. | ||||
|         """ | ||||
|         response = self.client.get('/get_view/') | ||||
|         self.assertEqual(response.resolver_match.url_name, 'get_view') | ||||
|  | ||||
|     def test_raw_post(self): | ||||
|         "POST raw data (with a content type) to a view" | ||||
|         test_doc = """<?xml version="1.0" encoding="utf-8"?><library><book><title>Blink</title><author>Malcolm Gladwell</author></book></library>""" | ||||
|   | ||||
| @@ -5,7 +5,7 @@ from . import views | ||||
|  | ||||
|  | ||||
| urlpatterns = [ | ||||
|     url(r'^get_view/$', views.get_view), | ||||
|     url(r'^get_view/$', views.get_view, name='get_view'), | ||||
|     url(r'^post_view/$', views.post_view), | ||||
|     url(r'^header_view/$', views.view_with_header), | ||||
|     url(r'^raw_post_view/$', views.raw_post_view), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user