diff options
Diffstat (limited to 'tests/test_client')
| -rw-r--r-- | tests/test_client/tests.py | 40 | ||||
| -rw-r--r-- | tests/test_client/views.py | 2 |
2 files changed, 13 insertions, 29 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 8d28c0816d..d3eb782347 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -103,9 +103,8 @@ class ClientTest(TestCase): def test_response_attached_request(self): """ - Check that the returned response has a ``request`` attribute with the - originating environ dict and a ``wsgi_request`` with the originating - ``WSGIRequest`` instance. + The returned response has a ``request`` attribute with the originating + environ dict and a ``wsgi_request`` with the originating WSGIRequest. """ response = self.client.get("/header_view/") @@ -164,34 +163,28 @@ class ClientTest(TestCase): def test_redirect(self): "GET a URL that redirects elsewhere" response = self.client.get('/redirect_view/') - # Check that the response was a 302 (redirect) self.assertRedirects(response, '/get_view/') def test_redirect_with_query(self): "GET a URL that redirects with given GET parameters" response = self.client.get('/redirect_view/', {'var': 'value'}) - - # Check if parameters are intact self.assertRedirects(response, '/get_view/?var=value') def test_permanent_redirect(self): "GET a URL that redirects permanently elsewhere" response = self.client.get('/permanent_redirect_view/') - # Check that the response was a 301 (permanent redirect) self.assertRedirects(response, '/get_view/', status_code=301) def test_temporary_redirect(self): "GET a URL that does a non-permanent redirect" response = self.client.get('/temporary_redirect_view/') - # Check that the response was a 302 (non-permanent redirect) self.assertRedirects(response, '/get_view/', status_code=302) def test_redirect_to_strange_location(self): "GET a URL that redirects to a non-200 page" response = self.client.get('/double_redirect_view/') - - # Check that the response was a 302, and that - # the attempt to get the redirection location returned 301 when retrieved + # The response was a 302, and that the attempt to get the redirection + # location returned 301 when retrieved self.assertRedirects(response, '/permanent_redirect_view/', target_status_code=301) def test_follow_redirect(self): @@ -225,8 +218,6 @@ class ClientTest(TestCase): def test_notfound_response(self): "GET a URL that responds as '404:Not Found'" response = self.client.get('/bad_view/') - - # Check that the response was a 404, and that the content contains MAGIC self.assertContains(response, 'MAGIC', status_code=404) def test_valid_form(self): @@ -251,7 +242,7 @@ class ClientTest(TestCase): response = self.client.get('/form_view/', data=hints) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "Form GET Template") - # Check that the multi-value data has been rolled out ok + # The multi-value data has been rolled out ok self.assertContains(response, 'Select a valid choice.', 0) def test_incomplete_data_form(self): @@ -336,14 +327,14 @@ class ClientTest(TestCase): "GET an invalid URL" response = self.client.get('/unknown_view/') - # Check that the response was a 404 + # The response was a 404 self.assertEqual(response.status_code, 404) def test_url_parameters(self): "Make sure that URL ;-parameters are not stripped." response = self.client.get('/unknown_view/;some-parameter') - # Check that the path in the response includes it (ignore that it's a 404) + # The path in the response includes it (ignore that it's a 404) self.assertEqual(response.request['PATH_INFO'], '/unknown_view/;some-parameter') def test_view_with_login(self): @@ -617,7 +608,7 @@ class ClientTest(TestCase): def test_external_redirect_with_fetch_error_msg(self): """ - Check that assertRedirects without fetch_redirect_response=False raises + assertRedirects without fetch_redirect_response=False raises a relevant ValueError rather than a non-descript AssertionError. """ response = self.client.get('/django_project_redirect/') @@ -637,7 +628,7 @@ class ClientTest(TestCase): self.client.session['tobacconist'] self.client.post('/session_view/') - # Check that the session was modified + # The session was modified self.assertEqual(self.client.session['tobacconist'], 'hovercraft') @override_settings( @@ -661,8 +652,7 @@ class ClientTest(TestCase): self.client.get("/broken_view/") def test_mail_sending(self): - "Test that mail is redirected to a dummy outbox during test setup" - + "Mail is redirected to a dummy outbox during test setup" response = self.client.get('/mail_sending_view/') self.assertEqual(response.status_code, 200) @@ -674,7 +664,7 @@ class ClientTest(TestCase): self.assertEqual(mail.outbox[0].to[1], 'second@example.com') def test_reverse_lazy_decodes(self): - "Ensure reverse_lazy works in the test client" + "reverse_lazy() works in the test client" data = {'var': 'data'} response = self.client.get(reverse_lazy('get_view'), data) @@ -690,8 +680,7 @@ class ClientTest(TestCase): self.assertRedirects(response, '/accounts/login/') def test_mass_mail_sending(self): - "Test that mass mail is redirected to a dummy outbox during test setup" - + "Mass mail is redirected to a dummy outbox during test setup" response = self.client.get('/mass_mail_sending_view/') self.assertEqual(response.status_code, 200) @@ -736,11 +725,9 @@ class CSRFEnabledClientTests(SimpleTestCase): def test_csrf_enabled_client(self): "A client can be instantiated with CSRF checks enabled" csrf_client = Client(enforce_csrf_checks=True) - # The normal client allows the post response = self.client.post('/post_view/', {}) self.assertEqual(response.status_code, 200) - # The CSRF-enabled client rejects it response = csrf_client.post('/post_view/', {}) self.assertEqual(response.status_code, 403) @@ -787,7 +774,6 @@ class RequestFactoryTest(SimpleTestCase): method = getattr(self.request_factory, method_name) request = method('/somewhere/') response = view(request) - self.assertEqual(response.status_code, 200) def test_get_request_from_factory(self): @@ -796,7 +782,6 @@ class RequestFactoryTest(SimpleTestCase): """ request = self.request_factory.get('/somewhere/') response = get_view(request) - self.assertContains(response, 'This is a test') def test_trace_request_from_factory(self): @@ -806,5 +791,4 @@ class RequestFactoryTest(SimpleTestCase): response = trace_view(request) protocol = request.META["SERVER_PROTOCOL"] echoed_request_line = "TRACE {} {}".format(url_path, protocol) - self.assertContains(response, echoed_request_line) diff --git a/tests/test_client/views.py b/tests/test_client/views.py index 6e7d3a37d5..41106d78ff 100644 --- a/tests/test_client/views.py +++ b/tests/test_client/views.py @@ -176,7 +176,7 @@ def form_view_with_template(request): class BaseTestFormSet(BaseFormSet): def clean(self): - """Checks that no two email addresses are the same.""" + """No two email addresses are the same.""" if any(self.errors): # Don't bother validating the formset unless each form is valid return |
