From fa75b2cb512409116b6f1b5229d6f99074d8e452 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 7 Feb 2018 14:20:04 -0500 Subject: [PATCH] Refs #27795 -- Removed force_bytes/text() usage in tests. --- tests/admin_utils/test_logentry.py | 6 +++--- tests/admin_views/tests.py | 28 ++++++++++++------------- tests/auth_tests/test_hashers.py | 3 +-- tests/auth_tests/test_templates.py | 3 +-- tests/auth_tests/test_views.py | 3 +-- tests/file_uploads/tests.py | 5 ++--- tests/file_uploads/views.py | 5 ++--- tests/gis_tests/geos_tests/test_geos.py | 3 +-- tests/mail/tests.py | 9 ++++---- tests/view_tests/tests/test_debug.py | 3 +-- 10 files changed, 29 insertions(+), 39 deletions(-) diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py index 1cf0de349d..64ff5fec3e 100644 --- a/tests/admin_utils/test_logentry.py +++ b/tests/admin_utils/test_logentry.py @@ -8,7 +8,6 @@ from django.contrib.contenttypes.models import ContentType from django.test import TestCase, override_settings from django.urls import reverse from django.utils import translation -from django.utils.encoding import force_bytes from django.utils.html import escape from .models import Article, ArticleProxy, Site @@ -211,9 +210,10 @@ class LogEntryTests(TestCase): logentry.content_type = None logentry.save() - counted_presence_before = response.content.count(force_bytes(should_contain)) + should_contain = should_contain.encode() + counted_presence_before = response.content.count(should_contain) response = self.client.get(reverse('admin:index')) - counted_presence_after = response.content.count(force_bytes(should_contain)) + counted_presence_after = response.content.count(should_contain) self.assertEqual(counted_presence_before - 1, counted_presence_after) def test_proxy_model_content_type_is_used_for_log_entries(self): diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 68094e0053..3089307ba2 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -29,7 +29,7 @@ from django.test.utils import override_script_prefix, patch_logger from django.urls import NoReverseMatch, resolve, reverse from django.utils import formats, translation from django.utils.cache import get_max_age -from django.utils.encoding import force_bytes, force_text, iri_to_uri +from django.utils.encoding import iri_to_uri from django.utils.html import escape from django.utils.http import urlencode @@ -183,8 +183,8 @@ class AdminViewBasicTestCase(TestCase): """ self.assertEqual(response.status_code, 200) self.assertLess( - response.content.index(force_bytes(text1)), - response.content.index(force_bytes(text2)), + response.content.index(text1.encode()), + response.content.index(text2.encode()), (failing_msg or '') + '\nResponse:\n' + response.content.decode(response.charset) ) @@ -2161,16 +2161,14 @@ class AdminViewDeletedObjectsTest(TestCase): cause them to be scheduled for deletion. """ pattern = re.compile( - force_bytes( - r'
  • Plot: World Domination\s*