summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2017-01-20 10:20:53 +0100
committerClaude Paroz <claude@2xlibre.net>2017-01-20 14:13:55 +0100
commit042b7350a080cc964f913faf1cf7f0097f650a58 (patch)
tree4ad77d8fc8ae016770afe01a543a6042fa02357a /tests
parent4e729feaa647547f25debb1cb63dec989dc41a20 (diff)
Refs #23919 -- Removed unneeded str() calls
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_scripts/tests.py7
-rw-r--r--tests/auth_tests/test_management.py5
-rw-r--r--tests/builtin_server/tests.py8
-rw-r--r--tests/forms_tests/tests/tests.py4
-rw-r--r--tests/get_object_or_404/tests.py2
-rw-r--r--tests/get_or_create/tests.py2
-rw-r--r--tests/httpwrappers/tests.py31
-rw-r--r--tests/i18n/test_compilation.py2
-rw-r--r--tests/i18n/tests.py22
-rw-r--r--tests/mail/tests.py20
-rw-r--r--tests/migrations/test_writer.py19
-rw-r--r--tests/servers/test_basehttp.py2
-rw-r--r--tests/str/tests.py4
-rw-r--r--tests/urlpatterns_reverse/tests.py4
-rw-r--r--tests/utils_tests/test_encoding.py4
15 files changed, 46 insertions, 90 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 25e6487a0f..bccefc2d19 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -145,14 +145,13 @@ class AdminScriptTestCase(unittest.TestCase):
# Set the test environment
if settings_file:
- test_environ['DJANGO_SETTINGS_MODULE'] = str(settings_file)
+ test_environ['DJANGO_SETTINGS_MODULE'] = settings_file
elif 'DJANGO_SETTINGS_MODULE' in test_environ:
del test_environ['DJANGO_SETTINGS_MODULE']
python_path = [base_dir, django_dir, tests_dir]
python_path.extend(ext_backend_base_dirs)
- # Use native strings for better compatibility
- test_environ[str(python_path_var_name)] = os.pathsep.join(python_path)
- test_environ[str('PYTHONWARNINGS')] = str('')
+ test_environ[python_path_var_name] = os.pathsep.join(python_path)
+ test_environ['PYTHONWARNINGS'] = ''
# Move to the test directory and run
os.chdir(self.test_dir)
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index 00864be47a..15ff551211 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -37,10 +37,7 @@ def mock_inputs(inputs):
return inputs['password']
def mock_input(prompt):
- # prompt should be encoded in Python 2. This line will raise an
- # Exception if prompt contains unencoded non-ASCII on Python 2.
- prompt = str(prompt)
- assert str('__proxy__') not in prompt
+ assert '__proxy__' not in prompt
response = ''
for key, val in inputs.items():
if key in prompt.lower():
diff --git a/tests/builtin_server/tests.py b/tests/builtin_server/tests.py
index 6e234c1ba4..a294339f85 100644
--- a/tests/builtin_server/tests.py
+++ b/tests/builtin_server/tests.py
@@ -10,7 +10,7 @@ MAX_SOCKET_CHUNK_SIZE = 32 * 1024 * 1024 # 32 MB
class ServerHandler(simple_server.ServerHandler):
- error_status = str("500 INTERNAL SERVER ERROR")
+ error_status = "500 INTERNAL SERVER ERROR"
def write(self, data):
"""'write()' callable as specified by PEP 3333"""
@@ -55,12 +55,12 @@ class FileWrapperHandler(ServerHandler):
def wsgi_app(environ, start_response):
- start_response(str('200 OK'), [(str('Content-Type'), str('text/plain'))])
+ start_response('200 OK', [('Content-Type', 'text/plain')])
return [b'Hello World!']
def wsgi_app_file_wrapper(environ, start_response):
- start_response(str('200 OK'), [(str('Content-Type'), str('text/plain'))])
+ start_response('200 OK', [('Content-Type', 'text/plain')])
return environ['wsgi.file_wrapper'](BytesIO(b'foo'))
@@ -113,7 +113,7 @@ class WriteChunkCounterHandler(ServerHandler):
def send_big_data_app(environ, start_response):
- start_response(str('200 OK'), [(str('Content-Type'), str('text/plain'))])
+ start_response('200 OK', [('Content-Type', 'text/plain')])
# Return a blob of data that is 1.5 times the maximum chunk size.
return [b'x' * (MAX_SOCKET_CHUNK_SIZE + MAX_SOCKET_CHUNK_SIZE // 2)]
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 0119410fc8..fe72474537 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -248,7 +248,7 @@ class RelatedModelFormTests(SimpleTestCase):
fields = '__all__'
with self.assertRaises(ValueError):
- ModelFormMetaclass(str('Form'), (ModelForm,), {'Meta': Meta})
+ ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta})
class B(models.Model):
pass
@@ -267,7 +267,7 @@ class RelatedModelFormTests(SimpleTestCase):
model = C
fields = '__all__'
- self.assertTrue(issubclass(ModelFormMetaclass(str('Form'), (ModelForm,), {'Meta': Meta}), ModelForm))
+ self.assertTrue(issubclass(ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta}), ModelForm))
class ManyToManyExclusionTestCase(TestCase):
diff --git a/tests/get_object_or_404/tests.py b/tests/get_object_or_404/tests.py
index fa3c0cb324..a72b766524 100644
--- a/tests/get_object_or_404/tests.py
+++ b/tests/get_object_or_404/tests.py
@@ -81,7 +81,7 @@ class GetObjectOr404Tests(TestCase):
# raises a helpful ValueError message
msg = "First argument to get_object_or_404() must be a Model, Manager, or QuerySet, not 'str'."
with self.assertRaisesMessage(ValueError, msg):
- get_object_or_404(str("Article"), title__icontains="Run")
+ get_object_or_404("Article", title__icontains="Run")
class CustomClass:
pass
diff --git a/tests/get_or_create/tests.py b/tests/get_or_create/tests.py
index 27a0cb7737..a2a6e5a5a5 100644
--- a/tests/get_or_create/tests.py
+++ b/tests/get_or_create/tests.py
@@ -201,7 +201,7 @@ class GetOrCreateTestsWithManualPKs(TestCase):
ManualPrimaryKeyTest.objects.get_or_create(id=1, data="Different")
except IntegrityError:
formatted_traceback = traceback.format_exc()
- self.assertIn(str('obj.save'), formatted_traceback)
+ self.assertIn('obj.save', formatted_traceback)
# MySQL emits a warning when broken data is saved
@ignore_warnings(module='django.db.backends.mysql.base')
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index 612cbb45ef..c58163b014 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -21,7 +21,7 @@ from django.utils.functional import lazystr
class QueryDictTests(SimpleTestCase):
def test_create_with_no_args(self):
- self.assertEqual(QueryDict(), QueryDict(str('')))
+ self.assertEqual(QueryDict(), QueryDict(''))
def test_missing_key(self):
q = QueryDict()
@@ -63,7 +63,7 @@ class QueryDictTests(SimpleTestCase):
def test_single_key_value(self):
"""Test QueryDict with one key/value pair"""
- q = QueryDict(str('foo=bar'))
+ q = QueryDict('foo=bar')
self.assertEqual(q['foo'], 'bar')
with self.assertRaises(KeyError):
q.__getitem__('bar')
@@ -166,7 +166,7 @@ class QueryDictTests(SimpleTestCase):
def test_multiple_keys(self):
"""Test QueryDict with two key/value pairs with same keys."""
- q = QueryDict(str('vote=yes&vote=no'))
+ q = QueryDict('vote=yes&vote=no')
self.assertEqual(q['vote'], 'no')
with self.assertRaises(AttributeError):
@@ -209,23 +209,23 @@ class QueryDictTests(SimpleTestCase):
q = QueryDict()
q1 = pickle.loads(pickle.dumps(q, 2))
self.assertEqual(q, q1)
- q = QueryDict(str('a=b&c=d'))
+ q = QueryDict('a=b&c=d')
q1 = pickle.loads(pickle.dumps(q, 2))
self.assertEqual(q, q1)
- q = QueryDict(str('a=b&c=d&a=1'))
+ q = QueryDict('a=b&c=d&a=1')
q1 = pickle.loads(pickle.dumps(q, 2))
self.assertEqual(q, q1)
def test_update_from_querydict(self):
"""Regression test for #8278: QueryDict.update(QueryDict)"""
- x = QueryDict(str("a=1&a=2"), mutable=True)
- y = QueryDict(str("a=3&a=4"))
+ x = QueryDict("a=1&a=2", mutable=True)
+ y = QueryDict("a=3&a=4")
x.update(y)
self.assertEqual(x.getlist('a'), ['1', '2', '3', '4'])
def test_non_default_encoding(self):
"""#13572 - QueryDict with a non-default encoding"""
- q = QueryDict(str('cur=%A4'), encoding='iso-8859-15')
+ q = QueryDict('cur=%A4', encoding='iso-8859-15')
self.assertEqual(q.encoding, 'iso-8859-15')
self.assertEqual(list(q.items()), [('cur', '€')])
self.assertEqual(q.urlencode(), 'cur=%A4')
@@ -280,16 +280,11 @@ class HttpResponseTests(unittest.TestCase):
def test_headers_type(self):
r = HttpResponse()
- # The following tests explicitly test types in addition to values
- # because in Python 2 u'foo' == b'foo'.
-
- # ASCII unicode or bytes values are converted to native strings.
+ # ASCII unicode or bytes values are converted to strings.
r['key'] = 'test'
- self.assertEqual(r['key'], str('test'))
- self.assertIsInstance(r['key'], str)
+ self.assertEqual(r['key'], 'test')
r['key'] = 'test'.encode('ascii')
- self.assertEqual(r['key'], str('test'))
- self.assertIsInstance(r['key'], str)
+ self.assertEqual(r['key'], 'test')
self.assertIn(b'test', r.serialize_headers())
# Non-ASCII values are serialized to Latin-1.
@@ -298,8 +293,7 @@ class HttpResponseTests(unittest.TestCase):
# Other unicode values are MIME-encoded (there's no way to pass them as bytes).
r['key'] = '†'
- self.assertEqual(r['key'], str('=?utf-8?b?4oCg?='))
- self.assertIsInstance(r['key'], str)
+ self.assertEqual(r['key'], '=?utf-8?b?4oCg?=')
self.assertIn(b'=?utf-8?b?4oCg?=', r.serialize_headers())
# The response also converts unicode or bytes keys to strings, but requires
@@ -310,7 +304,6 @@ class HttpResponseTests(unittest.TestCase):
headers = list(r.items())
self.assertEqual(len(headers), 1)
self.assertEqual(headers[0], ('foo', 'bar'))
- self.assertIsInstance(headers[0][0], str)
r = HttpResponse()
del r['Content-Type']
diff --git a/tests/i18n/test_compilation.py b/tests/i18n/test_compilation.py
index 159b6d91ec..5244832e2d 100644
--- a/tests/i18n/test_compilation.py
+++ b/tests/i18n/test_compilation.py
@@ -142,7 +142,7 @@ class CompilationErrorHandling(MessageCompilationTests):
# po file contains invalid msgstr content (triggers non-ascii error content).
# Make sure the output of msgfmt is unaffected by the current locale.
env = os.environ.copy()
- env.update({str('LANG'): str('C')})
+ env.update({'LANG': 'C'})
with mock.patch('django.core.management.utils.Popen', lambda *args, **kwargs: Popen(*args, env=env, **kwargs)):
cmd = MakeMessagesCommand()
if cmd.gettext_version < (0, 18, 3):
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index 181de62bea..4f4801ba2c 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -24,8 +24,8 @@ from django.utils.safestring import SafeBytes, SafeText
from django.utils.translation import (
LANGUAGE_SESSION_KEY, activate, check_for_language, deactivate,
get_language, get_language_from_request, get_language_info, gettext_lazy,
- ngettext_lazy, npgettext, npgettext_lazy, pgettext, trans_real, ugettext,
- ugettext_lazy, ungettext, ungettext_lazy,
+ npgettext, npgettext_lazy, pgettext, trans_real, ugettext, ugettext_lazy,
+ ungettext, ungettext_lazy,
)
from .forms import CompanyForm, I18nForm, SelectDateForm
@@ -146,14 +146,11 @@ class TranslationTests(SimpleTestCase):
@override_settings(LOCALE_PATHS=extended_locale_paths)
def test_ungettext_lazy(self):
simple_with_format = ungettext_lazy('%d good result', '%d good results')
- simple_str_with_format = ngettext_lazy(str('%d good result'), str('%d good results'))
simple_context_with_format = npgettext_lazy('Exclamation', '%d good result', '%d good results')
simple_without_format = ungettext_lazy('good result', 'good results')
with translation.override('de'):
self.assertEqual(simple_with_format % 1, '1 gutes Resultat')
self.assertEqual(simple_with_format % 4, '4 guten Resultate')
- self.assertEqual(simple_str_with_format % 1, str('1 gutes Resultat'))
- self.assertEqual(simple_str_with_format % 4, str('4 guten Resultate'))
self.assertEqual(simple_context_with_format % 1, '1 gutes Resultat!')
self.assertEqual(simple_context_with_format % 4, '4 guten Resultate!')
self.assertEqual(simple_without_format % 1, 'gutes Resultat')
@@ -163,12 +160,6 @@ class TranslationTests(SimpleTestCase):
complex_deferred = ungettext_lazy(
'Hi %(name)s, %(num)d good result', 'Hi %(name)s, %(num)d good results', 'num'
)
- complex_str_nonlazy = ngettext_lazy(
- str('Hi %(name)s, %(num)d good result'), str('Hi %(name)s, %(num)d good results'), 4
- )
- complex_str_deferred = ngettext_lazy(
- str('Hi %(name)s, %(num)d good result'), str('Hi %(name)s, %(num)d good results'), 'num'
- )
complex_context_nonlazy = npgettext_lazy(
'Greeting', 'Hi %(name)s, %(num)d good result', 'Hi %(name)s, %(num)d good results', 4
)
@@ -181,11 +172,6 @@ class TranslationTests(SimpleTestCase):
self.assertEqual(complex_deferred % {'name': 'Jim', 'num': 5}, 'Hallo Jim, 5 guten Resultate')
with self.assertRaisesMessage(KeyError, 'Your dictionary lacks key'):
complex_deferred % {'name': 'Jim'}
- self.assertEqual(complex_str_nonlazy % {'num': 4, 'name': 'Jim'}, str('Hallo Jim, 4 guten Resultate'))
- self.assertEqual(complex_str_deferred % {'name': 'Jim', 'num': 1}, str('Hallo Jim, 1 gutes Resultat'))
- self.assertEqual(complex_str_deferred % {'name': 'Jim', 'num': 5}, str('Hallo Jim, 5 guten Resultate'))
- with self.assertRaisesMessage(KeyError, 'Your dictionary lacks key'):
- complex_str_deferred % {'name': 'Jim'}
self.assertEqual(complex_context_nonlazy % {'num': 4, 'name': 'Jim'}, 'Willkommen Jim, 4 guten Resultate')
self.assertEqual(complex_context_deferred % {'name': 'Jim', 'num': 1}, 'Willkommen Jim, 1 gutes Resultat')
self.assertEqual(complex_context_deferred % {'name': 'Jim', 'num': 5}, 'Willkommen Jim, 5 guten Resultate')
@@ -917,8 +903,8 @@ class FormattingTests(SimpleTestCase):
def test_get_format_modules_stability(self):
with self.settings(FORMAT_MODULE_PATH='i18n.other.locale'):
with translation.override('de', deactivate=True):
- old = str("%r") % get_format_modules(reverse=True)
- new = str("%r") % get_format_modules(reverse=True) # second try
+ old = "%r" % get_format_modules(reverse=True)
+ new = "%r" % get_format_modules(reverse=True) # second try
self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
def test_localize_templatetag_and_filter(self):
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 8019f3ccf8..f30734d72f 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -576,7 +576,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
s = msg.message().as_bytes()
self.assertIn(b'Content-Transfer-Encoding: 8bit', s)
s = msg.message().as_string()
- self.assertIn(str('Content-Transfer-Encoding: 8bit'), s)
+ self.assertIn('Content-Transfer-Encoding: 8bit', s)
msg = EmailMessage(
'Subject', 'Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.', 'bounce@example.com',
@@ -585,7 +585,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
s = msg.message().as_bytes()
self.assertIn(b'Content-Transfer-Encoding: 8bit', s)
s = msg.message().as_string()
- self.assertIn(str('Content-Transfer-Encoding: 8bit'), s)
+ self.assertIn('Content-Transfer-Encoding: 8bit', s)
def test_dont_base64_encode_message_rfc822(self):
# Ticket #18967
@@ -608,7 +608,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
parent_s = parent_msg.message().as_string()
# The child message header is not base64 encoded
- self.assertIn(str('Child Subject'), parent_s)
+ self.assertIn('Child Subject', parent_s)
# Feature test: try attaching email.Message object directly to the mail.
parent_msg = EmailMessage(
@@ -619,7 +619,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
parent_s = parent_msg.message().as_string()
# The child message header is not base64 encoded
- self.assertIn(str('Child Subject'), parent_s)
+ self.assertIn('Child Subject', parent_s)
# Feature test: try attaching Django's EmailMessage object directly to the mail.
parent_msg = EmailMessage(
@@ -630,7 +630,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
parent_s = parent_msg.message().as_string()
# The child message header is not base64 encoded
- self.assertIn(str('Child Subject'), parent_s)
+ self.assertIn('Child Subject', parent_s)
def test_sanitize_address(self):
"""
@@ -700,11 +700,11 @@ class PythonGlobalState(SimpleTestCase):
def test_8bit_latin(self):
txt = MIMEText('Body with latin characters: àáä.', 'plain', 'utf-8')
- self.assertIn(str('Content-Transfer-Encoding: base64'), txt.as_string())
+ self.assertIn('Content-Transfer-Encoding: base64', txt.as_string())
def test_8bit_non_latin(self):
txt = MIMEText('Body with non latin characters: А Б В Г Д Е Ж Ѕ З И І К Л М Н О П.', 'plain', 'utf-8')
- self.assertIn(str('Content-Transfer-Encoding: base64'), txt.as_string())
+ self.assertIn('Content-Transfer-Encoding: base64', txt.as_string())
class BaseEmailBackendTests(HeadersCheckMixin):
@@ -1091,7 +1091,7 @@ class ConsoleBackendTests(BaseEmailBackendTests, SimpleTestCase):
self.stream = sys.stdout = StringIO()
def get_mailbox_content(self):
- messages = self.stream.getvalue().split(str('\n' + ('-' * 79) + '\n'))
+ messages = self.stream.getvalue().split('\n' + ('-' * 79) + '\n')
return [message_from_bytes(force_bytes(m)) for m in messages if m]
def test_console_stream_kwarg(self):
@@ -1127,9 +1127,9 @@ class FakeSMTPChannel(smtpd.SMTPChannel):
# This is only the first part of the login process. But it's enough
# for our tests.
challenge = base64.b64encode(b'somerandomstring13579')
- self.push(str('334 %s' % challenge.decode()))
+ self.push('334 %s' % challenge.decode())
else:
- self.push(str('502 Error: login "%s" not implemented' % arg))
+ self.push('502 Error: login "%s" not implemented' % arg)
class FakeSMTPServer(smtpd.SMTPServer, threading.Thread):
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 0528583fcc..ec48e2ee8e 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -6,9 +6,7 @@ import math
import os
import re
import sys
-import tokenize
import uuid
-from io import StringIO
import custom_migration_operations.more_operations
import custom_migration_operations.operations
@@ -20,7 +18,7 @@ from django.db import migrations, models
from django.db.migrations.writer import (
MigrationWriter, OperationWriter, SettingsReference,
)
-from django.test import SimpleTestCase, ignore_warnings, mock
+from django.test import SimpleTestCase, mock
from django.utils import datetime_safe
from django.utils.deconstruct import deconstructible
from django.utils.functional import SimpleLazyObject
@@ -552,22 +550,7 @@ class WriterTests(SimpleTestCase):
# Just make sure it runs for now, and that things look alright.
result = self.safe_exec(output)
self.assertIn("Migration", result)
- # In order to preserve compatibility with Python 3.2 unicode literals
- # prefix shouldn't be added to strings.
- tokens = tokenize.generate_tokens(StringIO(str(output)).readline)
- for token_type, token_source, (srow, scol), __, line in tokens:
- if token_type == tokenize.STRING:
- self.assertFalse(
- token_source.startswith('u'),
- "Unicode literal prefix found at %d:%d: %r" % (
- srow, scol, line.strip()
- )
- )
- # Silence warning on Python 2: Not importing directory
- # 'tests/migrations/migrations_test_apps/without_init_file/migrations':
- # missing __init__.py
- @ignore_warnings(category=ImportWarning)
def test_migration_path(self):
test_apps = [
'migrations.migrations_test_apps.normal',
diff --git a/tests/servers/test_basehttp.py b/tests/servers/test_basehttp.py
index cf0f8ac41b..2e547c4305 100644
--- a/tests/servers/test_basehttp.py
+++ b/tests/servers/test_basehttp.py
@@ -60,7 +60,7 @@ class WSGIRequestHandlerTestCase(SimpleTestCase):
handler = WSGIRequestHandler(request, '192.168.0.2', None)
with patch_logger('django.server', 'error') as messages:
- handler.log_message("GET %s %s", str('\x16\x03'), "4")
+ handler.log_message("GET %s %s", '\x16\x03', "4")
self.assertIn(
"You're accessing the development server over HTTPS, "
"but it only supports HTTP.",
diff --git a/tests/str/tests.py b/tests/str/tests.py
index 2d82c03ebf..db21ccb2d9 100644
--- a/tests/str/tests.py
+++ b/tests/str/tests.py
@@ -30,5 +30,5 @@ class SimpleTests(TestCase):
# coerce the returned value.
self.assertIsInstance(obj.__str__(), str)
self.assertIsInstance(obj.__repr__(), str)
- self.assertEqual(str(obj), str('Default object'))
- self.assertEqual(repr(obj), str('<Default: Default object>'))
+ self.assertEqual(str(obj), 'Default object')
+ self.assertEqual(repr(obj), '<Default: Default object>')
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index a7f7c2fcc8..a1241b2fab 100644
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -356,7 +356,7 @@ class URLPatternReverse(SimpleTestCase):
def test_illegal_kwargs_message(self):
msg = "Reverse for 'places' with keyword arguments '{'arg1': 2}' not found. 1 pattern(s) tried:"
with self.assertRaisesMessage(NoReverseMatch, msg):
- reverse('places', kwargs={str('arg1'): 2})
+ reverse('places', kwargs={'arg1': 2})
class ResolverTests(SimpleTestCase):
@@ -436,7 +436,7 @@ class ResolverTests(SimpleTestCase):
)
for tried, expected in zip(e.args[0]['tried'], url_types_names):
for t, e in zip(tried, expected):
- self.assertIsInstance(t, e['type']), str('%s is not an instance of %s') % (t, e['type'])
+ self.assertIsInstance(t, e['type']), '%s is not an instance of %s' % (t, e['type'])
if 'name' in e:
if not e['name']:
self.assertIsNone(t.name, 'Expected no URL name but found %s.' % t.name)
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py
index ca9343674d..963d0a9a16 100644
--- a/tests/utils_tests/test_encoding.py
+++ b/tests/utils_tests/test_encoding.py
@@ -12,14 +12,12 @@ from django.utils.http import urlquote_plus
class TestEncodingUtils(unittest.TestCase):
def test_force_text_exception(self):
"""
- Broken __unicode__/__str__ actually raises an error.
+ Broken __str__ actually raises an error.
"""
class MyString:
def __str__(self):
return b'\xc3\xb6\xc3\xa4\xc3\xbc'
- __unicode__ = __str__
-
# str(s) raises a TypeError if the result is not a text type.
with self.assertRaises(TypeError):
force_text(MyString())