From 13dba4dba3ad52a8accee6778fb029fe81565d40 Mon Sep 17 00:00:00 2001 From: Alex Morozov Date: Sat, 21 Nov 2015 17:00:11 +0300 Subject: [PATCH] Fixed #25780 -- Removed redundant status code assertions from tests --- tests/admin_custom_urls/tests.py | 4 ---- tests/admin_inlines/tests.py | 1 - tests/admin_views/tests.py | 27 ------------------------ tests/flatpages_tests/test_csrf.py | 3 --- tests/flatpages_tests/test_middleware.py | 6 ------ tests/flatpages_tests/test_views.py | 3 --- tests/generic_views/test_base.py | 1 - tests/handlers/tests.py | 4 ---- tests/template_tests/test_response.py | 1 - tests/test_client/tests.py | 2 -- tests/view_tests/tests/test_i18n.py | 1 - 11 files changed, 53 deletions(-) diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index 2255ff59dcf..eff23931ef4 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -62,7 +62,6 @@ class AdminCustomUrlsTest(TestCase): string works. """ response = self.client.get(reverse('admin_custom_urls:admin_custom_urls_action_add'), {'name': 'My Action'}) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Action"') def test_basic_add_POST(self): @@ -75,7 +74,6 @@ class AdminCustomUrlsTest(TestCase): "description": "Description of added action", } response = self.client.post(reverse('admin_custom_urls:admin_custom_urls_action_add'), post_data) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissAddRelatedObjectPopup') self.assertContains(response, 'Action added through a popup') @@ -88,7 +86,6 @@ class AdminCustomUrlsTest(TestCase): url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote('add'),)) response = self.client.get(url) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'Change action') # Should correctly get the change_view for the model instance with the @@ -96,7 +93,6 @@ class AdminCustomUrlsTest(TestCase): url = reverse('admin_custom_urls:%s_action_change' % Action._meta.app_label, args=(quote("path/to/html/document.html"),)) response = self.client.get(url) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'Change action') self.assertContains(response, 'value="path/to/html/document.html"') diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index ea6dcbf517f..4f2377b2dee 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -492,7 +492,6 @@ class TestInlineProtectedOnDelete(TestDataMixin, TestCase): 'chapter_set-0-DELETE': 'on' } response = self.client.post(change_url, data) - self.assertEqual(response.status_code, 200) self.assertContains(response, "Deleting chapter %s would require deleting " "the following protected related objects: foot note %s" % (chapter, foot_note)) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 48182f2a4a7..910d7ff32da 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -227,7 +227,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_add_with_GET_args(self): response = self.client.get(reverse('admin:admin_views_section_add'), {'name': 'My Section'}) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'value="My Section"', msg_prefix="Couldn't find an input with the right value in the response") @@ -292,7 +291,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): 'date_1': '14:55:39', } response = self.client.post(reverse('admin:admin_views_article_add'), post_data) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissAddRelatedObjectPopup') self.assertContains(response, 'title with a new\\u000Aline') @@ -512,7 +510,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): This also tests relation-spanning filters (e.g. 'color__value'). """ response = self.client.get(reverse('admin:admin_views_thing_changelist')) - self.assertEqual(response.status_code, 200) self.assertContains(response, '
', msg_prefix="Expected filter not found in changelist view") self.assertNotContains(response, 'Blue', @@ -521,7 +518,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): def test_relation_spanning_filters(self): changelist_url = reverse('admin:admin_views_chapterxtra1_changelist') response = self.client.get(changelist_url) - self.assertEqual(response.status_code, 200) self.assertContains(response, '
') filters = { 'chap__id__exact': dict( @@ -682,7 +678,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): WorkHour.objects.create(datum=datetime.datetime.now(), employee=e1) WorkHour.objects.create(datum=datetime.datetime.now(), employee=e2) response = self.client.get(reverse('admin:admin_views_workhour_changelist')) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'employee__person_ptr__exact') response = self.client.get("%s?employee__person_ptr__exact=%d" % ( reverse('admin:admin_views_workhour_changelist'), e1.pk) @@ -1731,18 +1726,14 @@ class AdminViewPermissionsTest(TestCase): for login_dict in [self.joepublic_login, self.no_username_login]: self.client.post(login_url, login_dict) response = self.client.get(change_url_1, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') response = self.client.post(change_url_1, {'name': 'changed'}, follow=True) self.assertEqual(RowLevelChangePermissionModel.objects.get(id=1).name, 'odd id') - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') response = self.client.get(change_url_2, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') response = self.client.post(change_url_2, {'name': 'changed again'}, follow=True) self.assertEqual(RowLevelChangePermissionModel.objects.get(id=2).name, 'changed') - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') self.client.get(reverse('admin:logout')) @@ -1820,11 +1811,9 @@ class AdminViewPermissionsTest(TestCase): self.client.post(login_url, login_dict) url = reverse('admin:admin_views_rowlevelchangepermissionmodel_history', args=(rl1.pk,)) response = self.client.get(url, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') url = reverse('admin:admin_views_rowlevelchangepermissionmodel_history', args=(rl2.pk,)) response = self.client.get(url, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'login-form') self.client.get(reverse('admin:logout')) @@ -4488,14 +4477,12 @@ class PrePopulatedTest(TestCase): def test_prepopulated_on(self): response = self.client.get(reverse('admin:admin_views_prepopulatedpost_add')) - self.assertEqual(response.status_code, 200) self.assertContains(response, "id: '#id_slug',") self.assertContains(response, "field['dependency_ids'].push('#id_title');") self.assertContains(response, "id: '#id_prepopulatedsubpost_set-0-subslug',") def test_prepopulated_off(self): response = self.client.get(reverse('admin:admin_views_prepopulatedpost_change', args=(self.p1.pk,))) - self.assertEqual(response.status_code, 200) self.assertContains(response, "A Long Title") self.assertNotContains(response, "id: '#id_slug'") self.assertNotContains(response, "field['dependency_ids'].push('#id_title');") @@ -4910,7 +4897,6 @@ class ReadonlyTest(TestCase): """ p = FieldOverridePost.objects.create(title="Test Post", content="Test Content") response = self.client.get(reverse('admin:admin_views_fieldoverridepost_change', args=(p.pk,))) - self.assertEqual(response.status_code, 200) self.assertContains(response, '

Overridden help text for the date

') self.assertContains(response, '', html=True) self.assertNotContains(response, "Some help text for the date (with unicode ŠĐĆŽćžšđ)") @@ -5156,11 +5142,9 @@ class UserAdminTest(TestCase): def test_user_fk_add_popup(self): """User addition through a FK popup should return the appropriate JavaScript response.""" response = self.client.get(reverse('admin:admin_views_album_add')) - self.assertEqual(response.status_code, 200) self.assertContains(response, reverse('admin:auth_user_add')) self.assertContains(response, 'class="related-widget-wrapper-link add-related" id="add_id_owner"') response = self.client.get(reverse('admin:auth_user_add') + '?_popup=1') - self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'name="_continue"') self.assertNotContains(response, 'name="_addanother"') data = { @@ -5171,19 +5155,16 @@ class UserAdminTest(TestCase): '_save': '1', } response = self.client.post(reverse('admin:auth_user_add') + '?_popup=1', data, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissAddRelatedObjectPopup') def test_user_fk_change_popup(self): """User change through a FK popup should return the appropriate JavaScript response.""" response = self.client.get(reverse('admin:admin_views_album_add')) - self.assertEqual(response.status_code, 200) self.assertContains(response, reverse('admin:auth_user_change', args=('__fk__',))) self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"') user = User.objects.get(username='changeuser') url = reverse('admin:auth_user_change', args=(user.pk,)) + '?_popup=1' response = self.client.get(url) - self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'name="_continue"') self.assertNotContains(response, 'name="_addanother"') data = { @@ -5198,13 +5179,11 @@ class UserAdminTest(TestCase): '_save': '1', } response = self.client.post(url, data, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissChangeRelatedObjectPopup') def test_user_fk_delete_popup(self): """User deletion through a FK popup should return the appropriate JavaScript response.""" response = self.client.get(reverse('admin:admin_views_album_add')) - self.assertEqual(response.status_code, 200) self.assertContains(response, reverse('admin:auth_user_delete', args=('__fk__',))) self.assertContains(response, 'class="related-widget-wrapper-link change-related" id="change_id_owner"') user = User.objects.get(username='changeuser') @@ -5216,7 +5195,6 @@ class UserAdminTest(TestCase): '_popup': '1', } response = self.client.post(url, data, follow=True) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'dismissDeleteRelatedObjectPopup') def test_save_add_another_button(self): @@ -5360,7 +5338,6 @@ class CSSTest(TestCase): Ensure app and model tag are correctly read by change_form template """ response = self.client.get(reverse('admin:admin_views_section_add')) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'Isn't it flat!

") def test_view_non_existent_flatpage(self): @@ -72,13 +71,11 @@ class FlatpageCSRFTests(TestCase): User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/flatpage_root/sekrit/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it sekrit!

") def test_fallback_flatpage(self): "A flatpage can be served by the fallback middleware" response = self.client.get('/flatpage/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it flat!

") def test_fallback_non_existent_flatpage(self): diff --git a/tests/flatpages_tests/test_middleware.py b/tests/flatpages_tests/test_middleware.py index c6b040775ed..fd9bd11a5b1 100644 --- a/tests/flatpages_tests/test_middleware.py +++ b/tests/flatpages_tests/test_middleware.py @@ -57,7 +57,6 @@ class FlatpageMiddlewareTests(TestDataMixin, TestCase): def test_view_flatpage(self): "A flatpage can be served through a view, even when the middleware is in use" response = self.client.get('/flatpage_root/flatpage/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it flat!

") def test_view_non_existent_flatpage(self): @@ -72,13 +71,11 @@ class FlatpageMiddlewareTests(TestDataMixin, TestCase): User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/flatpage_root/sekrit/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it sekrit!

") def test_fallback_flatpage(self): "A flatpage can be served by the fallback middleware" response = self.client.get('/flatpage/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it flat!

") def test_fallback_non_existent_flatpage(self): @@ -93,7 +90,6 @@ class FlatpageMiddlewareTests(TestDataMixin, TestCase): User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/sekrit/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it sekrit!

") def test_fallback_flatpage_special_chars(self): @@ -108,7 +104,6 @@ class FlatpageMiddlewareTests(TestDataMixin, TestCase): fp.sites.add(settings.SITE_ID) response = self.client.get('/some.very_special~chars-here/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it special!

") @@ -176,5 +171,4 @@ class FlatpageMiddlewareAppendSlashTests(TestDataMixin, TestCase): fp.sites.add(settings.SITE_ID) response = self.client.get('/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Root

") diff --git a/tests/flatpages_tests/test_views.py b/tests/flatpages_tests/test_views.py index 4e9e38768b8..58dd2eb81ec 100644 --- a/tests/flatpages_tests/test_views.py +++ b/tests/flatpages_tests/test_views.py @@ -57,7 +57,6 @@ class FlatpageViewTests(TestDataMixin, TestCase): def test_view_flatpage(self): "A flatpage can be served through a view" response = self.client.get('/flatpage_root/flatpage/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it flat!

") def test_view_non_existent_flatpage(self): @@ -72,7 +71,6 @@ class FlatpageViewTests(TestDataMixin, TestCase): User.objects.create_user('testuser', 'test@example.com', 's3krit') self.client.login(username='testuser', password='s3krit') response = self.client.get('/flatpage_root/sekrit/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it sekrit!

") def test_fallback_flatpage(self): @@ -97,7 +95,6 @@ class FlatpageViewTests(TestDataMixin, TestCase): fp.sites.add(settings.SITE_ID) response = self.client.get('/flatpage_root/some.very_special~chars-here/') - self.assertEqual(response.status_code, 200) self.assertContains(response, "

Isn't it special!

") diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index 340d0a5f5ff..6d5045a81b5 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -247,7 +247,6 @@ class TemplateViewTest(SimpleTestCase): def _assert_about(self, response): response.render() - self.assertEqual(response.status_code, 200) self.assertContains(response, '

About

') def test_get(self): diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py index 76cfe5161c2..98919e49071 100644 --- a/tests/handlers/tests.py +++ b/tests/handlers/tests.py @@ -182,19 +182,15 @@ class HandlerNotFoundTest(SimpleTestCase): def test_invalid_urls(self): response = self.client.get('~%A9helloworld') - self.assertEqual(response.status_code, 404) self.assertContains(response, '~%A9helloworld', status_code=404) response = self.client.get('d%aao%aaw%aan%aal%aao%aaa%aad%aa/') - self.assertEqual(response.status_code, 404) self.assertContains(response, 'd%AAo%AAw%AAn%AAl%AAo%AAa%AAd%AA', status_code=404) response = self.client.get('/%E2%99%E2%99%A5/') - self.assertEqual(response.status_code, 404) self.assertContains(response, '%E2%99\u2665', status_code=404) response = self.client.get('/%E2%98%8E%E2%A9%E2%99%A5/') - self.assertEqual(response.status_code, 404) self.assertContains(response, '\u260e%E2%A9\u2665', status_code=404) def test_environ_path_info_type(self): diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py index 027584d2d71..05073b6f748 100644 --- a/tests/template_tests/test_response.py +++ b/tests/template_tests/test_response.py @@ -326,7 +326,6 @@ class CustomURLConfTest(SimpleTestCase): def test_custom_urlconf(self): response = self.client.get('/template_response_view/') - self.assertEqual(response.status_code, 200) self.assertContains(response, 'This is where you can find the snark: /snark/') diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index 4b483320855..cd3b6d77f9d 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -729,7 +729,6 @@ class RequestFactoryTest(SimpleTestCase): request = self.request_factory.get('/somewhere/') response = get_view(request) - self.assertEqual(response.status_code, 200) self.assertContains(response, 'This is a test') def test_trace_request_from_factory(self): @@ -740,5 +739,4 @@ class RequestFactoryTest(SimpleTestCase): protocol = request.META["SERVER_PROTOCOL"] echoed_request_line = "TRACE {} {}".format(url_path, protocol) - self.assertEqual(response.status_code, 200) self.assertContains(response, echoed_request_line) diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index a10a3bc7e1c..a586a7f66a3 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -208,7 +208,6 @@ class JsI18NTests(SimpleTestCase): """ with self.settings(LANGUAGE_CODE='en-us'), override('fr'): response = self.client.get('/jsi18n/app5/') - self.assertEqual(response.status_code, 200) self.assertContains(response, 'emoji') self.assertContains(response, '\\ud83d\\udca9')