summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_changelist/tests.py10
-rw-r--r--tests/admin_utils/models.py3
-rw-r--r--tests/admin_utils/test_logentry.py10
-rw-r--r--tests/admin_views/tests.py10
-rw-r--r--tests/admin_widgets/tests.py4
-rw-r--r--tests/auth_tests/test_management.py2
-rw-r--r--tests/backends/tests.py5
-rw-r--r--tests/contenttypes_tests/test_models.py3
-rw-r--r--tests/csrf_tests/tests.py3
-rw-r--r--tests/custom_columns/tests.py9
-rw-r--r--tests/custom_managers/tests.py9
-rw-r--r--tests/custom_pk/fields.py5
-rw-r--r--tests/custom_pk/tests.py17
-rw-r--r--tests/datatypes/tests.py3
-rw-r--r--tests/expressions/tests.py3
-rw-r--r--tests/expressions_case/tests.py7
-rw-r--r--tests/field_deconstruction/tests.py2
-rw-r--r--tests/field_defaults/tests.py3
-rw-r--r--tests/file_uploads/views.py3
-rw-r--r--tests/files/tests.py7
-rw-r--r--tests/fixtures_regress/models.py3
-rw-r--r--tests/forms_tests/field_tests/test_filepathfield.py3
-rw-r--r--tests/forms_tests/field_tests/test_typedchoicefield.py3
-rw-r--r--tests/forms_tests/tests/test_utils.py3
-rw-r--r--tests/forms_tests/tests/tests.py3
-rw-r--r--tests/gis_tests/geoadmin/tests.py2
-rw-r--r--tests/gis_tests/geoapp/test_functions.py3
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py13
-rw-r--r--tests/gis_tests/geos_tests/test_io.py3
-rw-r--r--tests/gis_tests/geos_tests/test_mutable_list.py3
-rw-r--r--tests/gis_tests/test_geoforms.py2
-rw-r--r--tests/gis_tests/test_geoip2.py3
-rw-r--r--tests/handlers/tests.py3
-rw-r--r--tests/httpwrappers/tests.py7
-rw-r--r--tests/i18n/contenttypes/tests.py6
-rw-r--r--tests/i18n/test_extraction.py3
-rw-r--r--tests/i18n/tests.py6
-rw-r--r--tests/inline_formsets/tests.py5
-rw-r--r--tests/lookup/models.py3
-rw-r--r--tests/m2m_and_m2o/models.py3
-rw-r--r--tests/m2m_intermediary/tests.py5
-rw-r--r--tests/mail/tests.py4
-rw-r--r--tests/migrations/test_state.py9
-rw-r--r--tests/migrations/test_writer.py2
-rw-r--r--tests/model_fields/test_foreignkey.py3
-rw-r--r--tests/model_fields/test_integerfield.py7
-rw-r--r--tests/model_fields/test_promises.py55
-rw-r--r--tests/model_forms/models.py3
-rw-r--r--tests/model_forms/tests.py34
-rw-r--r--tests/model_formsets/models.py3
-rw-r--r--tests/model_formsets/tests.py25
-rw-r--r--tests/model_formsets_regress/tests.py15
-rw-r--r--tests/model_inheritance/tests.py5
-rw-r--r--tests/model_regress/tests.py6
-rw-r--r--tests/order_with_respect_to/models.py3
-rw-r--r--tests/pagination/tests.py4
-rw-r--r--tests/prefetch_related/tests.py39
-rw-r--r--tests/queries/models.py3
-rw-r--r--tests/redirects_tests/tests.py3
-rw-r--r--tests/resolve_url/tests.py3
-rwxr-xr-xtests/runtests.py7
-rw-r--r--tests/save_delete_hooks/tests.py3
-rw-r--r--tests/select_related_regress/tests.py5
-rw-r--r--tests/serializers/models/base.py3
-rw-r--r--tests/serializers/test_xml.py3
-rw-r--r--tests/serializers/test_yaml.py3
-rw-r--r--tests/servers/tests.py3
-rw-r--r--tests/signals/tests.py3
-rw-r--r--tests/staticfiles_tests/cases.py5
-rw-r--r--tests/staticfiles_tests/test_management.py6
-rw-r--r--tests/staticfiles_tests/test_storage.py2
-rw-r--r--tests/template_tests/filter_tests/test_escape.py3
-rw-r--r--tests/template_tests/filter_tests/test_escapejs.py3
-rw-r--r--tests/template_tests/filter_tests/test_floatformat.py7
-rw-r--r--tests/template_tests/filter_tests/test_linebreaks.py3
-rw-r--r--tests/template_tests/filter_tests/test_slugify.py3
-rw-r--r--tests/template_tests/filter_tests/test_urlize.py3
-rw-r--r--tests/template_tests/templatetags/custom.py6
-rw-r--r--tests/template_tests/templatetags/inclusion.py10
-rw-r--r--tests/template_tests/test_unicode.py3
-rw-r--r--tests/test_utils/tests.py2
-rw-r--r--tests/update/models.py5
-rw-r--r--tests/urlpatterns_reverse/tests.py8
-rw-r--r--tests/utils_tests/test_encoding.py3
-rw-r--r--tests/utils_tests/test_functional.py7
-rw-r--r--tests/utils_tests/test_lazyobject.py2
-rw-r--r--tests/utils_tests/test_safestring.py4
-rw-r--r--tests/utils_tests/test_text.py3
88 files changed, 234 insertions, 313 deletions
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
index 48e7460314..33bf85a9ff 100644
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -12,7 +12,7 @@ from django.template import Context, Template
from django.test import TestCase, override_settings
from django.test.client import RequestFactory
from django.urls import reverse
-from django.utils import formats, six
+from django.utils import formats
from .admin import (
BandAdmin, ChildAdmin, ChordsBandAdmin, ConcertAdmin,
@@ -466,7 +466,7 @@ class ChangeListTests(TestCase):
event = Event.objects.create(date=datetime.date.today())
response = self.client.get(reverse('admin:admin_changelist_event_changelist'))
self.assertContains(response, formats.localize(event.date))
- self.assertNotContains(response, six.text_type(event.date))
+ self.assertNotContains(response, str(event.date))
def test_dynamic_list_display(self):
"""
@@ -581,9 +581,9 @@ class ChangeListTests(TestCase):
request = self._mocked_authenticated_request('/swallow/', superuser)
response = model_admin.changelist_view(request)
# just want to ensure it doesn't blow up during rendering
- self.assertContains(response, six.text_type(swallow.origin))
- self.assertContains(response, six.text_type(swallow.load))
- self.assertContains(response, six.text_type(swallow.speed))
+ self.assertContains(response, str(swallow.origin))
+ self.assertContains(response, str(swallow.load))
+ self.assertContains(response, str(swallow.speed))
# Reverse one-to-one relations should work.
self.assertContains(response, '<td class="field-swallowonetoone">-</td>')
self.assertContains(response, '<td class="field-swallowonetoone">%s</td>' % swallow_o2o)
diff --git a/tests/admin_utils/models.py b/tests/admin_utils/models.py
index 1af2f09411..cf90421e9a 100644
--- a/tests/admin_utils/models.py
+++ b/tests/admin_utils/models.py
@@ -1,5 +1,4 @@
from django.db import models
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
@@ -37,7 +36,7 @@ class Count(models.Model):
parent = models.ForeignKey('self', models.CASCADE, null=True)
def __str__(self):
- return six.text_type(self.num)
+ return str(self.num)
class Event(models.Model):
diff --git a/tests/admin_utils/test_logentry.py b/tests/admin_utils/test_logentry.py
index 89b25f462b..c2eee96f48 100644
--- a/tests/admin_utils/test_logentry.py
+++ b/tests/admin_utils/test_logentry.py
@@ -7,7 +7,7 @@ from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.urls import reverse
-from django.utils import six, translation
+from django.utils import translation
from django.utils.encoding import force_bytes
from django.utils.html import escape
@@ -164,17 +164,17 @@ class LogEntryTests(TestCase):
log_entry = LogEntry()
log_entry.action_flag = ADDITION
- self.assertTrue(six.text_type(log_entry).startswith('Added '))
+ self.assertTrue(str(log_entry).startswith('Added '))
log_entry.action_flag = CHANGE
- self.assertTrue(six.text_type(log_entry).startswith('Changed '))
+ self.assertTrue(str(log_entry).startswith('Changed '))
log_entry.action_flag = DELETION
- self.assertTrue(six.text_type(log_entry).startswith('Deleted '))
+ self.assertTrue(str(log_entry).startswith('Deleted '))
# Make sure custom action_flags works
log_entry.action_flag = 4
- self.assertEqual(six.text_type(log_entry), 'LogEntry Object')
+ self.assertEqual(str(log_entry), 'LogEntry Object')
def test_log_action(self):
content_type_pk = ContentType.objects.get_for_model(Article).pk
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index 2353a9ee7a..fb404e5fd2 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -29,7 +29,7 @@ from django.test import (
)
from django.test.utils import override_script_prefix, patch_logger
from django.urls import NoReverseMatch, resolve, reverse
-from django.utils import formats, six, translation
+from django.utils import formats, translation
from django.utils._os import upath
from django.utils.cache import get_max_age
from django.utils.deprecation import RemovedInDjango21Warning
@@ -3759,7 +3759,7 @@ class AdminCustomQuerysetTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(ShortMessage.objects.count(), 1)
# Message should contain non-ugly model verbose name. The ugly(!)
- # instance representation is set by six.text_type()
+ # instance representation is set by __str__().
self.assertContains(
response,
'<li class="success">The short message "<a href="%s">'
@@ -3806,7 +3806,7 @@ class AdminCustomQuerysetTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(Paper.objects.count(), 1)
# Message should contain non-ugly model verbose name. The ugly(!)
- # instance representation is set by six.text_type()
+ # instance representation is set by __str__().
self.assertContains(
response,
'<li class="success">The paper "<a href="%s">'
@@ -3863,8 +3863,8 @@ class AdminInlineFileUploadTest(TestCase):
"pictures-TOTAL_FORMS": "2",
"pictures-INITIAL_FORMS": "1",
"pictures-MAX_NUM_FORMS": "0",
- "pictures-0-id": six.text_type(self.picture.id),
- "pictures-0-gallery": six.text_type(self.gallery.id),
+ "pictures-0-id": str(self.picture.id),
+ "pictures-0-gallery": str(self.gallery.id),
"pictures-0-name": "Test Picture",
"pictures-0-image": "",
"pictures-1-id": "",
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 8eadab07d5..ae8443565d 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -17,7 +17,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models import CharField, DateField, DateTimeField
from django.test import SimpleTestCase, TestCase, override_settings
from django.urls import reverse
-from django.utils import six, translation
+from django.utils import translation
from .models import (
Advisor, Album, Band, Bee, Car, Company, Event, Honeycomb, Individual,
@@ -180,7 +180,7 @@ class AdminFormfieldForDBFieldTests(SimpleTestCase):
ma = AdvisorAdmin(Advisor, admin.site)
f = ma.formfield_for_dbfield(Advisor._meta.get_field('companies'), request=None)
self.assertEqual(
- six.text_type(f.help_text),
+ f.help_text,
'Hold down "Control", or "Command" on a Mac, to select more than one.'
)
diff --git a/tests/auth_tests/test_management.py b/tests/auth_tests/test_management.py
index ac57bbd511..9335b75dba 100644
--- a/tests/auth_tests/test_management.py
+++ b/tests/auth_tests/test_management.py
@@ -79,7 +79,7 @@ class GetDefaultUsernameTestCase(TestCase):
management.get_system_username = self.old_get_system_username
def test_actual_implementation(self):
- self.assertIsInstance(management.get_system_username(), six.text_type)
+ self.assertIsInstance(management.get_system_username(), str)
def test_simple(self):
management.get_system_username = lambda: 'joe'
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 7a102b040a..a7939ed8be 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -23,7 +23,6 @@ from django.test import (
SimpleTestCase, TestCase, TransactionTestCase, mock, override_settings,
skipIfDBFeature, skipUnlessDBFeature,
)
-from django.utils import six
from django.utils.six.moves import range
from .models import (
@@ -101,7 +100,7 @@ class OracleTests(unittest.TestCase):
# than 4000 chars and read it properly
with connection.cursor() as cursor:
cursor.execute('CREATE TABLE ltext ("TEXT" NCLOB)')
- long_str = ''.join(six.text_type(x) for x in range(4000))
+ long_str = ''.join(str(x) for x in range(4000))
cursor.execute('INSERT INTO ltext VALUES (%s)', [long_str])
cursor.execute('SELECT text FROM ltext')
row = cursor.fetchone()
@@ -419,7 +418,7 @@ class LastExecutedQueryTest(TestCase):
sql, params = data.query.sql_with_params()
cursor = data.query.get_compiler('default').execute_sql(CURSOR)
last_sql = cursor.db.ops.last_executed_query(cursor, sql, params)
- self.assertIsInstance(last_sql, six.text_type)
+ self.assertIsInstance(last_sql, str)
@unittest.skipUnless(connection.vendor == 'sqlite',
"This test is specific to SQLite.")
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py
index bb0f8c890f..4c16e0b4aa 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -3,7 +3,6 @@ from django.contrib.contenttypes.views import shortcut
from django.contrib.sites.shortcuts import get_current_site
from django.http import Http404, HttpRequest
from django.test import TestCase, override_settings
-from django.utils import six
from .models import (
ConcreteModel, FooWithBrokenAbsoluteUrl, FooWithoutUrl, FooWithUrl,
@@ -242,7 +241,7 @@ class ContentTypesTests(TestCase):
app_label='contenttypes',
model='OldModel',
)
- self.assertEqual(six.text_type(ct), 'OldModel')
+ self.assertEqual(str(ct), 'OldModel')
self.assertIsNone(ct.model_class())
# Make sure stale ContentTypes can be fetched like any other object.
diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py
index 33f30a8353..49247b7af8 100644
--- a/tests/csrf_tests/tests.py
+++ b/tests/csrf_tests/tests.py
@@ -13,7 +13,6 @@ from django.middleware.csrf import (
from django.test import SimpleTestCase, override_settings
from django.test.utils import patch_logger
from django.utils.encoding import force_bytes
-from django.utils.six import text_type
from django.views.decorators.csrf import csrf_exempt, requires_csrf_token
from .views import (
@@ -65,7 +64,7 @@ class CsrfViewMiddlewareTestMixin(object):
return req
def _check_token_present(self, response, csrf_id=None):
- text = text_type(response.content, response.charset)
+ text = str(response.content, response.charset)
match = re.search("name='csrfmiddlewaretoken' value='(.*?)'", text)
csrf_token = csrf_id or self._csrf_id
self.assertTrue(
diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py
index 04aca12914..2d7044b8de 100644
--- a/tests/custom_columns/tests.py
+++ b/tests/custom_columns/tests.py
@@ -1,6 +1,5 @@
from django.core.exceptions import FieldError
from django.test import TestCase
-from django.utils import six
from .models import Article, Author
@@ -20,7 +19,7 @@ class CustomColumnsTests(TestCase):
Author.objects.all(), [
"Peter Jones", "John Smith",
],
- six.text_type
+ str
)
def test_get_first_name(self):
@@ -34,7 +33,7 @@ class CustomColumnsTests(TestCase):
Author.objects.filter(first_name__exact="John"), [
"John Smith",
],
- six.text_type
+ str
)
def test_field_error(self):
@@ -54,7 +53,7 @@ class CustomColumnsTests(TestCase):
"Peter Jones",
"John Smith",
],
- six.text_type
+ str
)
def test_get_all_articles_for_an_author(self):
@@ -70,7 +69,7 @@ class CustomColumnsTests(TestCase):
self.article.authors.filter(last_name='Jones'), [
"Peter Jones"
],
- six.text_type
+ str
)
def test_author_querying(self):
diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py
index 1bfaf52766..54f3b58a79 100644
--- a/tests/custom_managers/tests.py
+++ b/tests/custom_managers/tests.py
@@ -1,6 +1,5 @@
from django.db import models
from django.test import TestCase
-from django.utils import six
from .models import (
Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager,
@@ -34,7 +33,7 @@ class CustomManagerTests(TestCase):
Person.objects.get_fun_people(), [
"Bugs Bunny"
],
- six.text_type
+ str
)
def test_queryset_copied_to_default(self):
@@ -67,12 +66,12 @@ class CustomManagerTests(TestCase):
for manager_name in self.custom_manager_names:
manager = getattr(Person, manager_name)
queryset = manager.filter()
- self.assertQuerysetEqual(queryset, ["Bugs Bunny"], six.text_type)
+ self.assertQuerysetEqual(queryset, ["Bugs Bunny"], str)
self.assertIs(queryset._filter_CustomQuerySet, True)
# Specialized querysets inherit from our custom queryset.
queryset = manager.values_list('first_name', flat=True).filter()
- self.assertEqual(list(queryset), [six.text_type("Bugs")])
+ self.assertEqual(list(queryset), ["Bugs"])
self.assertIs(queryset._filter_CustomQuerySet, True)
self.assertIsInstance(queryset.values(), CustomQuerySet)
@@ -99,7 +98,7 @@ class CustomManagerTests(TestCase):
Queryset method doesn't override the custom manager method.
"""
queryset = Person.custom_queryset_custom_manager.filter()
- self.assertQuerysetEqual(queryset, ["Bugs Bunny"], six.text_type)
+ self.assertQuerysetEqual(queryset, ["Bugs Bunny"], str)
self.assertIs(queryset._filter_CustomManager, True)
def test_related_manager(self):
diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py
index eb63f66679..fa61a72a0d 100644
--- a/tests/custom_pk/fields.py
+++ b/tests/custom_pk/fields.py
@@ -2,7 +2,6 @@ import random
import string
from django.db import models
-from django.utils import six
class MyWrapper(object):
@@ -50,12 +49,12 @@ class MyAutoField(models.CharField):
if not value:
return
if isinstance(value, MyWrapper):
- return six.text_type(value)
+ return str(value)
return value
def get_db_prep_value(self, value, connection, prepared=False):
if not value:
return
if isinstance(value, MyWrapper):
- return six.text_type(value)
+ return str(value)
return value
diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py
index 01150a46d2..7c89b6d120 100644
--- a/tests/custom_pk/tests.py
+++ b/tests/custom_pk/tests.py
@@ -1,6 +1,5 @@
from django.db import IntegrityError, transaction
from django.test import TestCase, skipIfDBFeature
-from django.utils import six
from .models import Bar, Business, Employee, Foo
@@ -25,14 +24,14 @@ class BasicCustomPKTests(TestCase):
Employee.objects.filter(pk=123), [
"Dan Jones",
],
- six.text_type
+ str
)
self.assertQuerysetEqual(
Employee.objects.filter(employee_code=123), [
"Dan Jones",
],
- six.text_type
+ str
)
self.assertQuerysetEqual(
@@ -40,7 +39,7 @@ class BasicCustomPKTests(TestCase):
"Fran Bones",
"Dan Jones",
],
- six.text_type
+ str
)
self.assertQuerysetEqual(
@@ -48,7 +47,7 @@ class BasicCustomPKTests(TestCase):
"Fran Bones",
"Dan Jones",
],
- six.text_type
+ str
)
self.assertQuerysetEqual(
@@ -73,7 +72,7 @@ class BasicCustomPKTests(TestCase):
"Fran Bones",
"Dan Jones",
],
- six.text_type
+ str
)
self.assertQuerysetEqual(
self.fran.business_set.all(), [
@@ -91,14 +90,14 @@ class BasicCustomPKTests(TestCase):
"Fran Bones",
"Dan Jones",
],
- six.text_type,
+ str,
)
self.assertQuerysetEqual(
Employee.objects.filter(business__pk="Sears"), [
"Fran Bones",
"Dan Jones",
],
- six.text_type,
+ str,
)
self.assertQuerysetEqual(
@@ -173,7 +172,7 @@ class BasicCustomPKTests(TestCase):
"Dan Jones",
"Fran Jones",
],
- six.text_type
+ str
)
diff --git a/tests/datatypes/tests.py b/tests/datatypes/tests.py
index b6899c7609..5c3dffa457 100644
--- a/tests/datatypes/tests.py
+++ b/tests/datatypes/tests.py
@@ -1,7 +1,6 @@
import datetime
from django.test import TestCase, skipIfDBFeature
-from django.utils import six
from django.utils.timezone import utc
from .models import Donut, RumBaba
@@ -75,7 +74,7 @@ class DataTypesTestCase(TestCase):
database should be unicode."""
d = Donut.objects.create(name='Jelly Donut', review='Outstanding')
newd = Donut.objects.get(id=d.id)
- self.assertIsInstance(newd.review, six.text_type)
+ self.assertIsInstance(newd.review, str)
@skipIfDBFeature('supports_timezones')
def test_error_on_timezone(self):
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index d3eabb6dbb..0a41494217 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -20,7 +20,6 @@ from django.db.models.sql import constants
from django.db.models.sql.datastructures import Join
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import Approximate
-from django.utils import six
from .models import (
UUID, Company, Employee, Experiment, Number, Result, SimulationRun, Time,
@@ -202,7 +201,7 @@ class BasicExpressionsTests(TestCase):
"Frank Meyer",
"Max Mustermann",
],
- lambda c: six.text_type(c.point_of_contact),
+ lambda c: str(c.point_of_contact),
ordered=False
)
diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py
index 414c4353a5..a662ffbc3b 100644
--- a/tests/expressions_case/tests.py
+++ b/tests/expressions_case/tests.py
@@ -9,7 +9,6 @@ from django.db import connection, models
from django.db.models import F, Max, Min, Q, Sum, Value
from django.db.models.expressions import Case, When
from django.test import TestCase
-from django.utils import six
from .models import CaseTestModel, Client, FKCaseTestModel, O2OCaseTestModel
@@ -648,7 +647,7 @@ class CaseExpressionTests(TestCase):
self.assertQuerysetEqual(
CaseTestModel.objects.all().order_by('pk'),
[(1, b'one'), (2, b'two'), (3, b''), (2, b'two'), (3, b''), (3, b''), (4, b'')],
- transform=lambda o: (o.integer, six.binary_type(o.binary))
+ transform=lambda o: (o.integer, bytes(o.binary))
)
def test_update_boolean(self):
@@ -757,7 +756,7 @@ class CaseExpressionTests(TestCase):
self.assertQuerysetEqual(
CaseTestModel.objects.all().order_by('pk'),
[(1, '~/1'), (2, '~/2'), (3, ''), (2, '~/2'), (3, ''), (3, ''), (4, '')],
- transform=lambda o: (o.integer, six.text_type(o.file))
+ transform=lambda o: (o.integer, str(o.file))
)
def test_update_file_path(self):
@@ -798,7 +797,7 @@ class CaseExpressionTests(TestCase):
self.assertQuerysetEqual(
CaseTestModel.objects.all().order_by('pk'),
[(1, '~/1'), (2, '~/2'), (3, ''), (2, '~/2'), (3, ''), (3, ''), (4, '')],
- transform=lambda o: (o.integer, six.text_type(o.image))
+ transform=lambda o: (o.integer, str(o.image))
)
def test_update_generic_ip_address(self):
diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
index bb16f4d76e..7b816b8bf0 100644
--- a/tests/field_deconstruction/tests.py
+++ b/tests/field_deconstruction/tests.py
@@ -2,7 +2,6 @@ from django.apps import apps
from django.db import models
from django.test import SimpleTestCase, override_settings
from django.test.utils import isolate_lru_cache
-from django.utils import six
class FieldDeconstructionTests(SimpleTestCase):
@@ -21,7 +20,6 @@ class FieldDeconstructionTests(SimpleTestCase):
field.set_attributes_from_name("is_awesome_test")
name, path, args, kwargs = field.deconstruct()
self.assertEqual(name, "is_awesome_test")
- self.assertIsInstance(name, six.text_type)
# Now try with a ForeignKey
field = models.ForeignKey("some_fake.ModelName", models.CASCADE)
name, path, args, kwargs = field.deconstruct()
diff --git a/tests/field_defaults/tests.py b/tests/field_defaults/tests.py
index 031fd75fe3..19b05aa537 100644
--- a/tests/field_defaults/tests.py
+++ b/tests/field_defaults/tests.py
@@ -1,7 +1,6 @@
from datetime import datetime
from django.test import TestCase
-from django.utils import six
from .models import Article
@@ -12,6 +11,6 @@ class DefaultTests(TestCase):
now = datetime.now()
a.save()
- self.assertIsInstance(a.id, six.integer_types)
+ self.assertIsInstance(a.id, int)
self.assertEqual(a.headline, "Default headline")
self.assertLess((now - a.pub_date).seconds, 5)
diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py
index bba71b87c2..c4166087ac 100644
--- a/tests/file_uploads/views.py
+++ b/tests/file_uploads/views.py
@@ -5,7 +5,6 @@ import os
from django.core.files.uploadedfile import UploadedFile
from django.http import HttpResponse, HttpResponseServerError
-from django.utils import six
from django.utils.encoding import force_bytes, force_str
from .models import FileModel
@@ -19,7 +18,7 @@ def file_upload_view(request):
"""
form_data = request.POST.copy()
form_data.update(request.FILES)
- if isinstance(form_data.get('file_field'), UploadedFile) and isinstance(form_data['name'], six.text_type):
+ if isinstance(form_data.get('file_field'), UploadedFile) and isinstance(form_data['name'], str):
# If a file is posted, the dummy client should only post the file name,
# not the full path.
if os.path.dirname(form_data['file_field'].name) != '':
diff --git a/tests/files/tests.py b/tests/files/tests.py
index a0ff3d4782..50db4b7436 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -11,7 +11,6 @@ from django.core.files.move import file_move_safe
from django.core.files.temp import NamedTemporaryFile
from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
from django.test import mock
-from django.utils import six
from django.utils._os import upath
try:
@@ -177,11 +176,11 @@ class ContentFileTestCase(unittest.TestCase):
def test_content_file_input_type(self):
"""
- ContentFile can accept both bytes and unicode and that the
- retrieved content is of the same type.
+ ContentFile can accept both bytes and strings and the retrieved content
+ is of the same type.
"""
self.assertIsInstance(ContentFile(b"content").read(), bytes)
- self.assertIsInstance(ContentFile("español").read(), six.text_type)
+ self.assertIsInstance(ContentFile("español").read(), str)
class DimensionClosingBug(unittest.TestCase):
diff --git a/tests/fixtures_regress/models.py b/tests/fixtures_regress/models.py
index a631fa44d1..d76642ac97 100644
--- a/tests/fixtures_regress/models.py
+++ b/tests/fixtures_regress/models.py
@@ -1,6 +1,5 @@
from django.contrib.auth.models import User
from django.db import models
-from django.utils import six
class Animal(models.Model):
@@ -29,7 +28,7 @@ class Stuff(models.Model):
owner = models.ForeignKey(User, models.SET_NULL, null=True)
def __str__(self):
- return six.text_type(self.name) + ' is owned by ' + six.text_type(self.owner)
+ return self.name + ' is owned by ' + str(self.owner)
class Absolute(models.Model):
diff --git a/tests/forms_tests/field_tests/test_filepathfield.py b/tests/forms_tests/field_tests/test_filepathfield.py
index 07ebe67f06..71164b5b7a 100644
--- a/tests/forms_tests/field_tests/test_filepathfield.py
+++ b/tests/forms_tests/field_tests/test_filepathfield.py
@@ -2,12 +2,11 @@ import os.path
from django.forms import FilePathField, ValidationError, forms
from django.test import SimpleTestCase
-from django.utils import six
from django.utils._os import upath
def fix_os_paths(x):
- if isinstance(x, six.string_types):
+ if isinstance(x, str):
return x.replace('\\', '/')
elif isinstance(x, tuple):
return tuple(fix_os_paths(list(x)))
diff --git a/tests/forms_tests/field_tests/test_typedchoicefield.py b/tests/forms_tests/field_tests/test_typedchoicefield.py
index c08a8bb611..bf0fdb4d47 100644
--- a/tests/forms_tests/field_tests/test_typedchoicefield.py
+++ b/tests/forms_tests/field_tests/test_typedchoicefield.py
@@ -2,7 +2,6 @@ import decimal
from django.forms import TypedChoiceField, ValidationError
from django.test import SimpleTestCase
-from django.utils import six
class TypedChoiceFieldTest(SimpleTestCase):
@@ -53,7 +52,7 @@ class TypedChoiceFieldTest(SimpleTestCase):
self.assertFalse(f.has_changed('1', '1'))
f = TypedChoiceField(
- choices=[('', '---------'), ('a', "a"), ('b', "b")], coerce=six.text_type,
+ choices=[('', '---------'), ('a', "a"), ('b', "b")], coerce=str,
required=False, initial=None, empty_value=None,
)
self.assertFalse(f.has_changed(None, ''))
diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py
index f06b60a620..f52c195637 100644
--- a/tests/forms_tests/tests/test_utils.py
+++ b/tests/forms_tests/tests/test_utils.py
@@ -3,7 +3,6 @@ import copy
from django.core.exceptions import ValidationError
from django.forms.utils import ErrorDict, ErrorList, flatatt
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy
@@ -63,7 +62,7 @@ class FormsUtilsTestCase(SimpleTestCase):
)
# Can take a unicode string.
self.assertHTMLEqual(
- six.text_type(ErrorList(ValidationError("Not \u03C0.").messages)),
+ str(ErrorList(ValidationError("Not \u03C0.").messages)),
'<ul class="errorlist"><li>Not π.</li></ul>'
)
# Can take a lazy string.
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 025b749762..0119410fc8 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -7,7 +7,6 @@ from django.forms import (
)
from django.forms.models import ModelFormMetaclass
from django.test import SimpleTestCase, TestCase
-from django.utils import six
from ..models import (
BoundaryModel, ChoiceFieldModel, ChoiceModel, ChoiceOptionModel, Defaults,
@@ -97,7 +96,7 @@ class ModelFormCallableModelDefault(TestCase):
choices = list(ChoiceFieldForm().fields['choice'].choices)
self.assertEqual(len(choices), 1)
- self.assertEqual(choices[0], (option.pk, six.text_type(option)))
+ self.assertEqual(choices[0], (option.pk, str(option)))
def test_callable_initial_value(self):
"The initial value for a callable default returning a queryset is the pk (refs #13769)"
diff --git a/tests/gis_tests/geoadmin/tests.py b/tests/gis_tests/geoadmin/tests.py
index 23fa8071b3..96877c26e3 100644
--- a/tests/gis_tests/geoadmin/tests.py
+++ b/tests/gis_tests/geoadmin/tests.py
@@ -96,6 +96,6 @@ class GeoAdminTest(TestCase):
self.assertEqual(len(logger_calls), 1)
self.assertEqual(
logger_calls[0],
- "Error creating geometry from value 'INVALID()' (String or unicode input "
+ "Error creating geometry from value 'INVALID()' (String input "
"unrecognized as WKT EWKT, and HEXEWKB.)"
)
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 2767b7974b..4d3913a7a3 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -7,7 +7,6 @@ from django.contrib.gis.measure import Area
from django.db import connection
from django.db.models import Sum
from django.test import TestCase, skipUnlessDBFeature
-from django.utils import six
from ..utils import mysql, oracle, postgis, spatialite
from .models import City, Country, CountryWebMercator, State, Track
@@ -361,7 +360,7 @@ class GISFunctionsTests(TestCase):
for bad_args in ((), range(3), range(5)):
with self.assertRaises(ValueError):
Country.objects.annotate(snap=functions.SnapToGrid('mpoly', *bad_args))
- for bad_args in (('1.0',), (1.0, None), tuple(map(six.text_type, range(4)))):
+ for bad_args in (('1.0',), (1.0, None), tuple(map(str, range(4)))):
with self.assertRaises(TypeError):
Country.objects.annotate(snap=functions.SnapToGrid('mpoly', *bad_args))
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index ff28eebf0f..7877e1f2d6 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -17,7 +17,6 @@ from django.contrib.gis.shortcuts import numpy
from django.template import Context
from django.template.engine import Engine
from django.test import SimpleTestCase, mock
-from django.utils import six
from django.utils.encoding import force_bytes
from django.utils.six.moves import range
@@ -65,8 +64,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self.assertIs(GEOSGeometry(hexewkb_3d).hasz, True)
# Same for EWKB.
- self.assertEqual(six.memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
- self.assertEqual(six.memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
+ self.assertEqual(memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
+ self.assertEqual(memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
# Redundant sanity check.
self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
@@ -88,7 +87,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
# Bad WKB
with self.assertRaises(GEOSException):
- GEOSGeometry(six.memoryview(b'0'))
+ GEOSGeometry(memoryview(b'0'))
class NotAGeometry(object):
pass
@@ -118,7 +117,7 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def test_create_wkb(self):
"Testing creation from WKB."
for g in self.geometries.hex_wkt:
- wkb = six.memoryview(a2b_hex(g.hex.encode()))
+ wkb = memoryview(a2b_hex(g.hex.encode()))
geom_h = GEOSGeometry(wkb)
# we need to do this so decimal places get normalized
geom_t = fromstr(g.wkt)
@@ -1164,13 +1163,13 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
g = GEOSGeometry("POINT(0 0)")
self.assertTrue(g.valid)
- self.assertIsInstance(g.valid_reason, six.string_types)
+ self.assertIsInstance(g.valid_reason, str)
self.assertEqual(g.valid_reason, "Valid Geometry")
g = GEOSGeometry("LINESTRING(0 0, 0 0)")
self.assertFalse(g.valid)
- self.assertIsInstance(g.valid_reason, six.string_types)
+ self.assertIsInstance(g.valid_reason, str)
self.assertTrue(g.valid_reason.startswith("Too few points in geometry component"))
def test_linearref(self):
diff --git a/tests/gis_tests/geos_tests/test_io.py b/tests/gis_tests/geos_tests/test_io.py
index 81e0ff357f..98b2aba3b4 100644
--- a/tests/gis_tests/geos_tests/test_io.py
+++ b/tests/gis_tests/geos_tests/test_io.py
@@ -6,7 +6,6 @@ from django.contrib.gis.geos import (
WKTWriter,
)
from django.test import SimpleTestCase
-from django.utils.six import memoryview
@skipUnless(HAS_GEOS, "Geos is required.")
@@ -25,7 +24,7 @@ class GEOSIOTest(SimpleTestCase):
for geom in (g1, g2):
self.assertEqual(ref, geom)
- # Should only accept six.string_types objects.
+ # Should only accept string objects.
with self.assertRaises(TypeError):
wkt_r.read(1)
with self.assertRaises(TypeError):
diff --git a/tests/gis_tests/geos_tests/test_mutable_list.py b/tests/gis_tests/geos_tests/test_mutable_list.py
index 3f7d8c30a1..26bdeb8045 100644
--- a/tests/gis_tests/geos_tests/test_mutable_list.py
+++ b/tests/gis_tests/geos_tests/test_mutable_list.py
@@ -7,7 +7,6 @@
import unittest
from django.contrib.gis.geos.mutable_list import ListMixin
-from django.utils import six
class UserListA(ListMixin):
@@ -298,7 +297,7 @@ class ListMixinTest(unittest.TestCase):
def test07_allowed_types(self):
'Type-restricted list'
pl, ul = self.lists_of_len()
- ul._allowed = six.integer_types
+ ul._allowed = int
ul[1] = 50
ul[:2] = [60, 70, 80]
diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py
index 27b80ce9b2..6fe0996721 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -132,7 +132,7 @@ class GeometryFieldTest(SimpleTestCase):
self.assertEqual(len(logger_calls), 1)
self.assertEqual(
logger_calls[0],
- "Error creating geometry from value 'PNT(0)' (String or unicode input "
+ "Error creating geometry from value 'PNT(0)' (String input "
"unrecognized as WKT EWKT, and HEXEWKB.)"
)
diff --git a/tests/gis_tests/test_geoip2.py b/tests/gis_tests/test_geoip2.py
index 54f20412a4..d35dcc336e 100644
--- a/tests/gis_tests/test_geoip2.py
+++ b/tests/gis_tests/test_geoip2.py
@@ -6,7 +6,6 @@ from django.conf import settings
from django.contrib.gis.geoip2 import HAS_GEOIP2
from django.contrib.gis.geos import HAS_GEOS, GEOSGeometry
from django.test import mock
-from django.utils import six
if HAS_GEOIP2:
from django.contrib.gis.geoip2 import GeoIP2, GeoIP2Exception
@@ -48,7 +47,7 @@ class GeoIPTest(unittest.TestCase):
for bad in bad_params:
with self.assertRaises(GeoIP2Exception):
GeoIP2(cache=bad)
- if isinstance(bad, six.string_types):
+ if isinstance(bad, str):
e = GeoIP2Exception
else:
e = TypeError
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py
index 72ba98b1d3..d7cfaadf62 100644
--- a/tests/handlers/tests.py
+++ b/tests/handlers/tests.py
@@ -7,7 +7,6 @@ from django.db import close_old_connections, connection
from django.test import (
RequestFactory, SimpleTestCase, TransactionTestCase, override_settings,
)
-from django.utils import six
from django.utils.encoding import force_str
try:
@@ -185,7 +184,7 @@ class HandlerRequestTests(SimpleTestCase):
def test_environ_path_info_type(self):
environ = RequestFactory().get('/%E2%A8%87%87%A5%E2%A8%A0').environ
- self.assertIsInstance(environ['PATH_INFO'], six.text_type)
+ self.assertIsInstance(environ['PATH_INFO'], str)
@unittest.skipIf(HTTPStatus is None, 'HTTPStatus only exists on Python 3.5+')
def test_handle_accepts_httpstatus_enum_value(self):
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index 9042f8ed6e..b8d359de41 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -578,7 +578,7 @@ class StreamingHttpResponseTests(SimpleTestCase):
chunks = list(r)
self.assertEqual(chunks, [b'hello', b'world'])
for chunk in chunks:
- self.assertIsInstance(chunk, six.binary_type)
+ self.assertIsInstance(chunk, bytes)
# and the response can only be iterated once.
self.assertEqual(list(r), [])
@@ -595,7 +595,7 @@ class StreamingHttpResponseTests(SimpleTestCase):
# '\xc3\xa9' == unichr(233).encode('utf-8')
self.assertEqual(chunks, [b'hello', b'caf\xc3\xa9'])
for chunk in chunks:
- self.assertIsInstance(chunk, six.binary_type)
+ self.assertIsInstance(chunk, bytes)
# streaming responses don't have a `content` attribute.
self.assertFalse(hasattr(r, 'content'))
@@ -616,8 +616,7 @@ class StreamingHttpResponseTests(SimpleTestCase):
# coercing a streaming response to bytes doesn't return a complete HTTP
# message like a regular response does. it only gives us the headers.
r = StreamingHttpResponse(iter(['hello', 'world']))
- self.assertEqual(
- six.binary_type(r), b'Content-Type: text/html; charset=utf-8')
+ self.assertEqual(bytes(r), b'Content-Type: text/html; charset=utf-8')
# and this won't consume its content.
self.assertEqual(list(r), [b'hello', b'world'])
diff --git a/tests/i18n/contenttypes/tests.py b/tests/i18n/contenttypes/tests.py
index 2a14e25972..94f355aba7 100644
--- a/tests/i18n/contenttypes/tests.py
+++ b/tests/i18n/contenttypes/tests.py
@@ -2,7 +2,7 @@ import os
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
-from django.utils import six, translation
+from django.utils import translation
from django.utils._os import upath
@@ -21,6 +21,6 @@ class ContentTypeTests(TestCase):
def test_verbose_name(self):
company_type = ContentType.objects.get(app_label='i18n', model='company')
with translation.override('en'):
- self.assertEqual(six.text_type(company_type), 'Company')
+ self.assertEqual(str(company_type), 'Company')
with translation.override('fr'):
- self.assertEqual(six.text_type(company_type), 'Société')
+ self.assertEqual(str(company_type), 'Société')
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index 33e136e1dd..b8342865a9 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -16,7 +16,6 @@ from django.core.management.commands.makemessages import \
from django.core.management.utils import find_command
from django.test import SimpleTestCase, mock, override_settings
from django.test.utils import captured_stderr, captured_stdout
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.six import StringIO
from django.utils.translation import TranslatorCommentWarning
@@ -69,7 +68,7 @@ class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase):
path = os.path.join(cwd_prefix, *comment_parts)
parts = [path]
- if isinstance(line_number, six.string_types):
+ if isinstance(line_number, str):
line_number = self._get_token_line_number(path, line_number)
if line_number is not None:
parts.append(':%d' % line_number)
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index d039d016ce..c3acdfe2fc 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -14,7 +14,7 @@ from django.template import Context, Template
from django.test import (
RequestFactory, SimpleTestCase, TestCase, override_settings,
)
-from django.utils import six, translation
+from django.utils import translation
from django.utils._os import upath
from django.utils.formats import (
date_format, get_format, get_format_modules, iter_format_modules, localize,
@@ -140,9 +140,9 @@ class TranslationTests(SimpleTestCase):
def test_lazy_pickle(self):
s1 = ugettext_lazy("test")
- self.assertEqual(six.text_type(s1), "test")
+ self.assertEqual(str(s1), "test")
s2 = pickle.loads(pickle.dumps(s1))
- self.assertEqual(six.text_type(s2), "test")
+ self.assertEqual(str(s2), "test")
@override_settings(LOCALE_PATHS=extended_locale_paths)
def test_ungettext_lazy(self):
diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py
index 0fb2fd2f02..fd51714cda 100644
--- a/tests/inline_formsets/tests.py
+++ b/tests/inline_formsets/tests.py
@@ -1,6 +1,5 @@
from django.forms.models import ModelForm, inlineformset_factory
from django.test import TestCase, skipUnlessDBFeature
-from django.utils import six
from .models import Child, Parent, Poem, Poet, School
@@ -65,8 +64,8 @@ class DeletionTests(TestCase):
'poem_set-TOTAL_FORMS': '1',
'poem_set-INITIAL_FORMS': '1',
'poem_set-MAX_NUM_FORMS': '0',
- 'poem_set-0-id': six.text_type(poem.id),
- 'poem_set-0-poem': six.text_type(poem.id),
+ 'poem_set-0-id': str(poem.id),
+ 'poem_set-0-poem': str(poem.id),
'poem_set-0-name': 'x' * 1000,
}
formset = PoemFormSet(data, instance=poet)
diff --git a/tests/lookup/models.py b/tests/lookup/models.py
index 9cf053d873..14742e8a8c 100644
--- a/tests/lookup/models.py
+++ b/tests/lookup/models.py
@@ -5,7 +5,6 @@ This demonstrates features of the database API.
"""
from django.db import models
-from django.utils import six
class Alarm(models.Model):
@@ -48,7 +47,7 @@ class Season(models.Model):
gt = models.IntegerField(null=True, blank=True)
def __str__(self):
- return six.text_type(self.year)
+ return str(self.year)
class Game(models.Model):
diff --git a/tests/m2m_and_m2o/models.py b/tests/m2m_and_m2o/models.py
index 7174e6369a..d9da2bf534 100644
--- a/tests/m2m_and_m2o/models.py
+++ b/tests/m2m_and_m2o/models.py
@@ -4,7 +4,6 @@ Many-to-many and many-to-one relationships to the same table
Make sure to set ``related_name`` if you use relationships to the same table.
"""
from django.db import models
-from django.utils import six
class User(models.Model):
@@ -17,7 +16,7 @@ class Issue(models.Model):
client = models.ForeignKey(User, models.CASCADE, related_name='test_issue_client')
def __str__(self):
- return six.text_type(self.num)
+ return str(self.num)
class Meta:
ordering = ('num',)
diff --git a/tests/m2m_intermediary/tests.py b/tests/m2m_intermediary/tests.py
index d429bf6516..215f6f86c6 100644
--- a/tests/m2m_intermediary/tests.py
+++ b/tests/m2m_intermediary/tests.py
@@ -1,7 +1,6 @@
from datetime import datetime
from django.test import TestCase
-from django.utils import six
from .models import Article, Reporter, Writer
@@ -23,7 +22,7 @@ class M2MIntermediaryTests(TestCase):
("John Smith", "Main writer"),
("Jane Doe", "Contributor"),
],
- lambda w: (six.text_type(w.reporter), w.position)
+ lambda w: (str(w.reporter), w.position)
)
self.assertEqual(w1.reporter, r1)
self.assertEqual(w2.reporter, r2)
@@ -35,5 +34,5 @@ class M2MIntermediaryTests(TestCase):
r1.writer_set.all(), [
("John Smith", "Main writer")
],
- lambda w: (six.text_type(w.reporter), w.position)
+ lambda w: (str(w.reporter), w.position)
)
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index cfe2889aa6..7c2cd8342a 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -26,7 +26,7 @@ from django.test import SimpleTestCase, override_settings
from django.test.utils import requires_tz_support
from django.utils._os import upath
from django.utils.encoding import force_bytes, force_text
-from django.utils.six import StringIO, binary_type
+from django.utils.six import StringIO
from django.utils.translation import ugettext_lazy
@@ -40,7 +40,7 @@ class HeadersCheckMixin(object):
with the contents of an email message.
headers: should be a set of (header-name, header-value) tuples.
"""
- if isinstance(message, binary_type):
+ if isinstance(message, bytes):
message = message_from_bytes(message)
msg_headers = set(message.items())
self.assertTrue(headers.issubset(msg_headers), msg='Message is missing '
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index c8eb1726ba..a6b027e079 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -10,7 +10,6 @@ from django.db.migrations.state import (
)
from django.test import SimpleTestCase, override_settings
from django.test.utils import isolate_apps
-from django.utils import six
from .models import (
FoodManager, FoodQuerySet, ModelWithCustomBase, NoMigrationFoodManager,
@@ -157,7 +156,7 @@ class StateTests(SimpleTestCase):
# The default manager is used in migrations
self.assertEqual([name for name, mgr in food_state.managers], ['food_mgr'])
- self.assertTrue(all(isinstance(name, six.text_type) for name, mgr in food_state.managers))
+ self.assertTrue(all(isinstance(name, str) for name, mgr in food_state.managers))
self.assertEqual(food_state.managers[0][1].args, ('a', 'b', 1, 2))
# No explicit managers defined. Migrations will fall back to the default
@@ -167,13 +166,13 @@ class StateTests(SimpleTestCase):
# default
self.assertEqual([name for name, mgr in food_no_default_manager_state.managers],
['food_no_mgr', 'food_mgr'])
- self.assertTrue(all(isinstance(name, six.text_type) for name, mgr in food_no_default_manager_state.managers))
+ self.assertTrue(all(isinstance(name, str) for name, mgr in food_no_default_manager_state.managers))
self.assertEqual(food_no_default_manager_state.managers[0][1].__class__, models.Manager)
self.assertIsInstance(food_no_default_manager_state.managers[1][1], FoodManager)
self.assertEqual([name for name, mgr in food_order_manager_state.managers],
['food_mgr1', 'food_mgr2'])
- self.assertTrue(all(isinstance(name, six.text_type) for name, mgr in food_order_manager_state.managers))
+ self.assertTrue(all(isinstance(name, str) for name, mgr in food_order_manager_state.managers))
self.assertEqual([mgr.args for name, mgr in food_order_manager_state.managers],
[('a', 'b', 1, 2), ('x', 'y', 3, 4)])
@@ -373,7 +372,7 @@ class StateTests(SimpleTestCase):
Food = new_apps.get_model("migrations", "Food")
self.assertEqual([mgr.name for mgr in Food._meta.managers],
['default', 'food_mgr1', 'food_mgr2'])
- self.assertTrue(all(isinstance(mgr.name, six.text_type) for mgr in Food._meta.managers))
+ self.assertTrue(all(isinstance(mgr.name, str) for mgr in Food._meta.managers))
self.assertEqual([mgr.__class__ for mgr in Food._meta.managers],
[models.Manager, FoodManager, FoodManager])
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index b926757920..59fd8eece5 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -42,7 +42,7 @@ class Money(decimal.Decimal):
def deconstruct(self):
return (
'%s.%s' % (self.__class__.__module__, self.__class__.__name__),
- [six.text_type(self)],
+ [str(self)],
{}
)
diff --git a/tests/model_fields/test_foreignkey.py b/tests/model_fields/test_foreignkey.py
index a521d1aa23..2580e3b650 100644
--- a/tests/model_fields/test_foreignkey.py
+++ b/tests/model_fields/test_foreignkey.py
@@ -5,7 +5,6 @@ from django.core import checks
from django.db import models
from django.test import TestCase, skipIfDBFeature
from django.test.utils import isolate_apps
-from django.utils import six
from .models import Bar, FkToChar, Foo, PrimaryKeyCharModel
@@ -50,7 +49,7 @@ class ForeignKeyTests(TestCase):
def test_related_name_converted_to_text(self):
rel_name = Bar._meta.get_field('a').remote_field.related_name
- self.assertIsInstance(rel_name, six.text_type)
+ self.assertIsInstance(rel_name, str)
def test_abstract_model_pending_operations(self):
"""
diff --git a/tests/model_fields/test_integerfield.py b/tests/model_fields/test_integerfield.py
index a474e6e602..99d7b1797c 100644
--- a/tests/model_fields/test_integerfield.py
+++ b/tests/model_fields/test_integerfield.py
@@ -2,7 +2,6 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.db import connection, models
from django.test import SimpleTestCase, TestCase
-from django.utils import six
from .models import (
BigIntegerModel, IntegerModel, PositiveIntegerModel,
@@ -121,11 +120,11 @@ class IntegerFieldTests(TestCase):
def test_types(self):
instance = self.model(value=0)
- self.assertIsInstance(instance.value, six.integer_types)
+ self.assertIsInstance(instance.value, int)
instance.save()
- self.assertIsInstance(instance.value, six.integer_types)
+ self.assertIsInstance(instance.value, int)
instance = self.model.objects.get()
- self.assertIsInstance(instance.value, six.integer_types)
+ self.assertIsInstance(instance.value, int)
def test_coercing(self):
self.model.objects.create(value='10')
diff --git a/tests/model_fields/test_promises.py b/tests/model_fields/test_promises.py
index 0dcb1abf3b..afbf36651a 100644
--- a/tests/model_fields/test_promises.py
+++ b/tests/model_fields/test_promises.py
@@ -10,7 +10,6 @@ from django.db.models.fields import (
)
from django.db.models.fields.files import FileField, ImageField
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.functional import lazy
@@ -29,10 +28,10 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(BooleanField().get_prep_value(lazy_func()), bool)
def test_CharField(self):
- lazy_func = lazy(lambda: '', six.text_type)
- self.assertIsInstance(CharField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: '', str)
+ self.assertIsInstance(CharField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(CharField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(CharField().get_prep_value(lazy_func()), str)
def test_DateField(self):
lazy_func = lazy(lambda: datetime.date.today(), datetime.date)
@@ -47,44 +46,44 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(DecimalField().get_prep_value(lazy_func()), Decimal)
def test_EmailField(self):
- lazy_func = lazy(lambda: 'mailbox@domain.com', six.text_type)
- self.assertIsInstance(EmailField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'mailbox@domain.com', str)
+ self.assertIsInstance(EmailField().get_prep_value(lazy_func()), str)
def test_FileField(self):
- lazy_func = lazy(lambda: 'filename.ext', six.text_type)
- self.assertIsInstance(FileField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'filename.ext', str)
+ self.assertIsInstance(FileField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(FileField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(FileField().get_prep_value(lazy_func()), str)
def test_FilePathField(self):
- lazy_func = lazy(lambda: 'tests.py', six.text_type)
- self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'tests.py', str)
+ self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(FilePathField().get_prep_value(lazy_func()), str)
def test_FloatField(self):
lazy_func = lazy(lambda: 1.2, float)
self.assertIsInstance(FloatField().get_prep_value(lazy_func()), float)
def test_ImageField(self):
- lazy_func = lazy(lambda: 'filename.ext', six.text_type)
- self.assertIsInstance(ImageField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'filename.ext', str)
+ self.assertIsInstance(ImageField().get_prep_value(lazy_func()), str)
def test_IntegerField(self):
lazy_func = lazy(lambda: 1, int)
self.assertIsInstance(IntegerField().get_prep_value(lazy_func()), int)
def test_IPAddressField(self):
- lazy_func = lazy(lambda: '127.0.0.1', six.text_type)
- self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: '127.0.0.1', str)
+ self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(IPAddressField().get_prep_value(lazy_func()), str)
def test_GenericIPAddressField(self):
- lazy_func = lazy(lambda: '127.0.0.1', six.text_type)
- self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: '127.0.0.1', str)
+ self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(GenericIPAddressField().get_prep_value(lazy_func()), str)
def test_NullBooleanField(self):
lazy_func = lazy(lambda: True, bool)
@@ -99,25 +98,25 @@ class PromiseTest(SimpleTestCase):
self.assertIsInstance(PositiveSmallIntegerField().get_prep_value(lazy_func()), int)
def test_SlugField(self):
- lazy_func = lazy(lambda: 'slug', six.text_type)
- self.assertIsInstance(SlugField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'slug', str)
+ self.assertIsInstance(SlugField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(SlugField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(SlugField().get_prep_value(lazy_func()), str)
def test_SmallIntegerField(self):
lazy_func = lazy(lambda: 1, int)
self.assertIsInstance(SmallIntegerField().get_prep_value(lazy_func()), int)
def test_TextField(self):
- lazy_func = lazy(lambda: 'Abc', six.text_type)
- self.assertIsInstance(TextField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'Abc', str)
+ self.assertIsInstance(TextField().get_prep_value(lazy_func()), str)
lazy_func = lazy(lambda: 0, int)
- self.assertIsInstance(TextField().get_prep_value(lazy_func()), six.text_type)
+ self.assertIsInstance(TextField().get_prep_value(lazy_func()), str)
def test_TimeField(self):
lazy_func = lazy(lambda: datetime.datetime.now().time(), datetime.time)
self.assertIsInstance(TimeField().get_prep_value(lazy_func()), datetime.time)
def test_URLField(self):
- lazy_func = lazy(lambda: 'http://domain.com', six.text_type)
- self.assertIsInstance(URLField().get_prep_value(lazy_func()), six.text_type)
+ lazy_func = lazy(lambda: 'http://domain.com', str)
+ self.assertIsInstance(URLField().get_prep_value(lazy_func()), str)
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
index 333a6050ab..0914fc2587 100644
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -15,7 +15,6 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
-from django.utils import six
from django.utils._os import upath
from django.utils.six.moves import range
@@ -319,7 +318,7 @@ class BigInt(models.Model):
biggie = models.BigIntegerField()
def __str__(self):
- return six.text_type(self.biggie)
+ return str(self.biggie)
class MarkupField(models.CharField):
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 0fc516b55c..27143e97f4 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1162,7 +1162,7 @@ class ModelFormBasicTests(TestCase):
# inserted as 'initial' data in each Field.
f = RoykoForm(auto_id=False, instance=self.w_royko)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Name:</th><td><input type="text" name="name" value="Mike Royko" maxlength="50" required /><br />
<span class="helptext">Use both first and last names.</span></td></tr>'''
)
@@ -1204,7 +1204,7 @@ class ModelFormBasicTests(TestCase):
'headline': 'Test headline',
'slug': 'test-headline',
'pub_date': '1984-02-06',
- 'writer': six.text_type(self.w_royko.pk),
+ 'writer': str(self.w_royko.pk),
'article': 'Hello.'
}, instance=art)
self.assertEqual(f.errors, {})
@@ -1294,7 +1294,7 @@ class ModelFormBasicTests(TestCase):
# fields with the 'choices' attribute are represented by a ChoiceField.
f = ArticleForm(auto_id=False)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr>
<tr><th>Slug:</th><td><input type="text" name="slug" maxlength="50" required /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>
@@ -1360,7 +1360,7 @@ class ModelFormBasicTests(TestCase):
f = PartialArticleForm(auto_id=False)
self.assertHTMLEqual(
- six.text_type(f),
+ str(f),
'''<tr><th>Headline:</th><td><input type="text" name="headline" maxlength="50" required /></td></tr>
<tr><th>Pub date:</th><td><input type="text" name="pub_date" required /></td></tr>''')
@@ -1398,9 +1398,9 @@ class ModelFormBasicTests(TestCase):
'headline': 'New headline',
'slug': 'new-headline',
'pub_date': '1988-01-04',
- 'writer': six.text_type(self.w_royko.pk),
+ 'writer': str(self.w_royko.pk),
'article': 'Hello.',
- 'categories': [six.text_type(self.c1.id), six.text_type(self.c2.id)]
+ 'categories': [str(self.c1.id), str(self.c2.id)]
}
# Create a new article, with categories, via the form.
f = ArticleForm(form_data)
@@ -1427,7 +1427,7 @@ class ModelFormBasicTests(TestCase):
# Create a new article, with categories, via the form, but use commit=False.
# The m2m data won't be saved until save_m2m() is invoked on the form.
- form_data['categories'] = [six.text_type(self.c1.id), six.text_type(self.c2.id)]
+ form_data['categories'] = [str(self.c1.id), str(self.c2.id)]
f = ArticleForm(form_data)
new_art = f.save(commit=False)
@@ -1979,12 +1979,12 @@ class ModelOneToOneFieldTests(TestCase):
)
data = {
- 'writer': six.text_type(self.w_woodward.pk),
+ 'writer': str(self.w_woodward.pk),
'age': '65',
}
form = WriterProfileForm(data)
instance = form.save()
- self.assertEqual(six.text_type(instance), 'Bob Woodward is 65')
+ self.assertEqual(str(instance), 'Bob Woodward is 65')
form = WriterProfileForm(instance=instance)
self.assertHTMLEqual(
@@ -2062,14 +2062,14 @@ class FileAndImageFieldTests(TestCase):
fields = '__all__'
form = DocumentForm()
- self.assertIn('name="myfile"', six.text_type(form))
- self.assertNotIn('myfile-clear', six.text_type(form))
+ self.assertIn('name="myfile"', str(form))
+ self.assertNotIn('myfile-clear', str(form))
form = DocumentForm(files={'myfile': SimpleUploadedFile('something.txt', b'content')})
self.assertTrue(form.is_valid())
doc = form.save(commit=False)
self.assertEqual(doc.myfile.name, 'something.txt')
form = DocumentForm(instance=doc)
- self.assertIn('myfile-clear', six.text_type(form))
+ self.assertIn('myfile-clear', str(form))
form = DocumentForm(instance=doc, data={'myfile-clear': 'true'})
doc = form.save(commit=False)
self.assertFalse(doc.myfile)
@@ -2094,7 +2094,7 @@ class FileAndImageFieldTests(TestCase):
self.assertTrue(not form.is_valid())
self.assertEqual(form.errors['myfile'],
['Please either submit a file or check the clear checkbox, not both.'])
- rendered = six.text_type(form)
+ rendered = str(form)
self.assertIn('something.txt', rendered)
self.assertIn('myfile-clear', rendered)
@@ -2469,7 +2469,7 @@ class OtherModelFormTests(TestCase):
# the ModelForm.
f = ModelFormWithMedia()
self.assertHTMLEqual(
- six.text_type(f.media),
+ str(f.media),
'''<link href="/some/form/css" type="text/css" media="all" rel="stylesheet" />
<script type="text/javascript" src="/some/form/javascript"></script>'''
)
@@ -2520,7 +2520,7 @@ class OtherModelFormTests(TestCase):
(22, 'Pear')))
form = InventoryForm(instance=core)
- self.assertHTMLEqual(six.text_type(form['parent']), '''<select name="parent" id="id_parent">
+ self.assertHTMLEqual(str(form['parent']), '''<select name="parent" id="id_parent">
<option value="">---------</option>
<option value="86" selected>Apple</option>
<option value="87">Core</option>
@@ -2543,7 +2543,7 @@ class OtherModelFormTests(TestCase):
['description', 'url'])
self.assertHTMLEqual(
- six.text_type(CategoryForm()),
+ str(CategoryForm()),
'''<tr><th><label for="id_description">Description:</label></th>
<td><input type="text" name="description" id="id_description" required /></td></tr>
<tr><th><label for="id_url">The URL:</label></th>
@@ -2564,7 +2564,7 @@ class OtherModelFormTests(TestCase):
self.assertEqual(list(CustomFieldForExclusionForm.base_fields),
['name'])
self.assertHTMLEqual(
- six.text_type(CustomFieldForExclusionForm()),
+ str(CustomFieldForExclusionForm()),
'''<tr><th><label for="id_name">Name:</label></th>
<td><input id="id_name" type="text" name="name" maxlength="10" required /></td></tr>'''
)
diff --git a/tests/model_formsets/models.py b/tests/model_formsets/models.py
index b7b1f1edb9..744a7f6019 100644
--- a/tests/model_formsets/models.py
+++ b/tests/model_formsets/models.py
@@ -2,7 +2,6 @@ import datetime
import uuid
from django.db import models
-from django.utils import six
class Author(models.Model):
@@ -172,7 +171,7 @@ class Revision(models.Model):
unique_together = (("repository", "revision"),)
def __str__(self):
- return "%s (%s)" % (self.revision, six.text_type(self.repository))
+ return "%s (%s)" % (self.revision, str(self.repository))
# models for testing callable defaults (see bug #7975). If you define a model
diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
index b928944097..832dbe63ee 100644
--- a/tests/model_formsets/tests.py
+++ b/tests/model_formsets/tests.py
@@ -11,7 +11,6 @@ from django.forms.models import (
modelformset_factory,
)
from django.test import TestCase, skipUnlessDBFeature
-from django.utils import six
from .models import (
AlternateBook, Author, AuthorMeeting, BetterAuthor, Book, BookWithCustomPK,
@@ -54,11 +53,11 @@ class DeletionTests(TestCase):
'form-TOTAL_FORMS': '3',
'form-INITIAL_FORMS': '1',
'form-MAX_NUM_FORMS': '0',
- 'form-0-id': six.text_type(poet.id),
+ 'form-0-id': str(poet.id),
'form-0-name': 'test',
'form-1-id': '',
'form-1-name': 'x' * 1000, # Too long
- 'form-2-id': six.text_type(poet.id), # Violate unique constraint
+ 'form-2-id': str(poet.id), # Violate unique constraint
'form-2-name': 'test2',
}
formset = PoetFormSet(data, queryset=Poet.objects.all())
@@ -87,7 +86,7 @@ class DeletionTests(TestCase):
'form-TOTAL_FORMS': '1',
'form-INITIAL_FORMS': '1',
'form-MAX_NUM_FORMS': '0',
- 'form-0-id': six.text_type(poet.id),
+ 'form-0-id': str(poet.id),
'form-0-name': 'x' * 1000,
}
formset = PoetFormSet(data, queryset=Poet.objects.all())
@@ -1109,7 +1108,7 @@ class ModelFormsetTest(TestCase):
'owner_set-TOTAL_FORMS': '3',
'owner_set-INITIAL_FORMS': '1',
'owner_set-MAX_NUM_FORMS': '',
- 'owner_set-0-auto_id': six.text_type(owner1.auto_id),
+ 'owner_set-0-auto_id': str(owner1.auto_id),
'owner_set-0-name': 'Joe Perry',
'owner_set-1-auto_id': '',
'owner_set-1-name': 'Jack Berry',
@@ -1184,7 +1183,7 @@ class ModelFormsetTest(TestCase):
'ownerprofile-TOTAL_FORMS': '1',
'ownerprofile-INITIAL_FORMS': '1',
'ownerprofile-MAX_NUM_FORMS': '1',
- 'ownerprofile-0-owner': six.text_type(owner1.auto_id),
+ 'ownerprofile-0-owner': str(owner1.auto_id),
'ownerprofile-0-age': '55',
}
formset = FormSet(data, instance=owner1)
@@ -1383,8 +1382,8 @@ class ModelFormsetTest(TestCase):
'membership_set-TOTAL_FORMS': '1',
'membership_set-INITIAL_FORMS': '0',
'membership_set-MAX_NUM_FORMS': '',
- 'membership_set-0-date_joined': six.text_type(now.strftime('%Y-%m-%d %H:%M:%S')),
- 'initial-membership_set-0-date_joined': six.text_type(now.strftime('%Y-%m-%d %H:%M:%S')),
+ 'membership_set-0-date_joined': now.strftime('%Y-%m-%d %H:%M:%S'),
+ 'initial-membership_set-0-date_joined': now.strftime('%Y-%m-%d %H:%M:%S'),
'membership_set-0-karma': '',
}
formset = FormSet(data, instance=person)
@@ -1397,8 +1396,8 @@ class ModelFormsetTest(TestCase):
'membership_set-TOTAL_FORMS': '1',
'membership_set-INITIAL_FORMS': '0',
'membership_set-MAX_NUM_FORMS': '',
- 'membership_set-0-date_joined': six.text_type(one_day_later.strftime('%Y-%m-%d %H:%M:%S')),
- 'initial-membership_set-0-date_joined': six.text_type(now.strftime('%Y-%m-%d %H:%M:%S')),
+ 'membership_set-0-date_joined': one_day_later.strftime('%Y-%m-%d %H:%M:%S'),
+ 'initial-membership_set-0-date_joined': now.strftime('%Y-%m-%d %H:%M:%S'),
'membership_set-0-karma': '',
}
formset = FormSet(filled_data, instance=person)
@@ -1429,9 +1428,9 @@ class ModelFormsetTest(TestCase):
'membership_set-TOTAL_FORMS': '1',
'membership_set-INITIAL_FORMS': '0',
'membership_set-MAX_NUM_FORMS': '',
- 'membership_set-0-date_joined_0': six.text_type(now.strftime('%Y-%m-%d')),
- 'membership_set-0-date_joined_1': six.text_type(now.strftime('%H:%M:%S')),
- 'initial-membership_set-0-date_joined': six.text_type(now.strftime('%Y-%m-%d %H:%M:%S')),
+ 'membership_set-0-date_joined_0': now.strftime('%Y-%m-%d'),
+ 'membership_set-0-date_joined_1': now.strftime('%H:%M:%S'),
+ 'initial-membership_set-0-date_joined': now.strftime('%Y-%m-%d %H:%M:%S'),
'membership_set-0-karma': '',
}
formset = FormSet(data, instance=person)
diff --git a/tests/model_formsets_regress/tests.py b/tests/model_formsets_regress/tests.py
index a9b50b3699..5bad8a741a 100644
--- a/tests/model_formsets_regress/tests.py
+++ b/tests/model_formsets_regress/tests.py
@@ -6,7 +6,6 @@ from django.forms.models import (
)
from django.forms.utils import ErrorDict, ErrorList
from django.test import TestCase
-from django.utils import six
from .models import (
Host, Manager, Network, ProfileNetwork, Restaurant, User, UserProfile,
@@ -56,7 +55,7 @@ class InlineFormsetTests(TestCase):
'usersite_set-TOTAL_FORMS': '1',
'usersite_set-INITIAL_FORMS': '1',
'usersite_set-MAX_NUM_FORMS': '0',
- 'usersite_set-0-id': six.text_type(usersite[0]['id']),
+ 'usersite_set-0-id': str(usersite[0]['id']),
'usersite_set-0-data': '11',
'usersite_set-0-user': 'apollo13'
}
@@ -74,7 +73,7 @@ class InlineFormsetTests(TestCase):
'usersite_set-TOTAL_FORMS': '2',
'usersite_set-INITIAL_FORMS': '1',
'usersite_set-MAX_NUM_FORMS': '0',
- 'usersite_set-0-id': six.text_type(usersite[0]['id']),
+ 'usersite_set-0-id': str(usersite[0]['id']),
'usersite_set-0-data': '11',
'usersite_set-0-user': 'apollo13',
'usersite_set-1-data': '42',
@@ -129,7 +128,7 @@ class InlineFormsetTests(TestCase):
'manager_set-TOTAL_FORMS': '1',
'manager_set-INITIAL_FORMS': '1',
'manager_set-MAX_NUM_FORMS': '0',
- 'manager_set-0-id': six.text_type(manager[0]['id']),
+ 'manager_set-0-id': str(manager[0]['id']),
'manager_set-0-name': 'Terry Gilliam'
}
form_set = FormSet(data, instance=restaurant)
@@ -145,7 +144,7 @@ class InlineFormsetTests(TestCase):
'manager_set-TOTAL_FORMS': '2',
'manager_set-INITIAL_FORMS': '1',
'manager_set-MAX_NUM_FORMS': '0',
- 'manager_set-0-id': six.text_type(manager[0]['id']),
+ 'manager_set-0-id': str(manager[0]['id']),
'manager_set-0-name': 'Terry Gilliam',
'manager_set-1-name': 'John Cleese'
}
@@ -226,7 +225,7 @@ class InlineFormsetTests(TestCase):
'host_set-TOTAL_FORMS': '2',
'host_set-INITIAL_FORMS': '1',
'host_set-MAX_NUM_FORMS': '0',
- 'host_set-0-id': six.text_type(host1.id),
+ 'host_set-0-id': str(host1.id),
'host_set-0-hostname': 'tranquility.hub.dal.net',
'host_set-1-hostname': 'matrix.de.eu.dal.net'
}
@@ -505,7 +504,7 @@ class RedeleteTests(TestCase):
'usersite_set-TOTAL_FORMS': '1',
'usersite_set-INITIAL_FORMS': '1',
'usersite_set-MAX_NUM_FORMS': '1',
- 'usersite_set-0-id': six.text_type(us.pk),
+ 'usersite_set-0-id': str(us.pk),
'usersite_set-0-data': '7',
'usersite_set-0-user': 'foo',
'usersite_set-0-DELETE': '1'
@@ -531,7 +530,7 @@ class RedeleteTests(TestCase):
'usersite_set-TOTAL_FORMS': '1',
'usersite_set-INITIAL_FORMS': '1',
'usersite_set-MAX_NUM_FORMS': '1',
- 'usersite_set-0-id': six.text_type(us.pk),
+ 'usersite_set-0-id': str(us.pk),
'usersite_set-0-data': '7',
'usersite_set-0-user': 'foo',
'usersite_set-0-DELETE': '1'
diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
index 8bb74d7ccb..feff4a1407 100644
--- a/tests/model_inheritance/tests.py
+++ b/tests/model_inheritance/tests.py
@@ -4,7 +4,6 @@ from django.core.exceptions import FieldError, ValidationError
from django.db import connection, models
from django.test import SimpleTestCase, TestCase
from django.test.utils import CaptureQueriesContext, isolate_apps
-from django.utils import six
from .models import (
Base, Chef, CommonInfo, GrandChild, GrandParent, ItalianRestaurant,
@@ -25,8 +24,8 @@ class ModelInheritanceTests(TestCase):
s = Student.objects.create(name="Pebbles", age=5, school_class="1B")
- self.assertEqual(six.text_type(w1), "Worker Fred")
- self.assertEqual(six.text_type(s), "Student Pebbles")
+ self.assertEqual(str(w1), "Worker Fred")
+ self.assertEqual(str(s), "Student Pebbles")
# The children inherit the Meta class of their parents (if they don't
# specify their own).
diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py
index 808729979f..e9374d9d93 100644
--- a/tests/model_regress/tests.py
+++ b/tests/model_regress/tests.py
@@ -5,7 +5,6 @@ from django.core.exceptions import ValidationError
from django.db import router
from django.db.models.sql import InsertQuery
from django.test import TestCase, skipUnlessDBFeature
-from django.utils import six
from django.utils.timezone import get_fixed_timezone
from .models import (
@@ -53,10 +52,9 @@ class ModelTests(TestCase):
# An empty choice field should return None for the display name.
self.assertIs(a.get_status_display(), None)
- # Empty strings should be returned as Unicode
+ # Empty strings should be returned as string
a = Article.objects.get(pk=a.pk)
self.assertEqual(a.misc_data, '')
- self.assertIs(type(a.misc_data), six.text_type)
def test_long_textfield(self):
# TextFields can hold more than 4000 characters (this was broken in
@@ -186,7 +184,7 @@ class ModelTests(TestCase):
# Check Department and Worker (non-default PK type)
d = Department.objects.create(id=10, name="IT")
w = Worker.objects.create(department=d, name="Full-time")
- self.assertEqual(six.text_type(w), "Full-time")
+ self.assertEqual(str(w), "Full-time")
def test_broken_unicode(self):
# Models with broken unicode methods should still have a printable repr
diff --git a/tests/order_with_respect_to/models.py b/tests/order_with_respect_to/models.py
index 8f50b42252..7f6cd8f8fd 100644
--- a/tests/order_with_respect_to/models.py
+++ b/tests/order_with_respect_to/models.py
@@ -3,7 +3,6 @@ Tests for the order_with_respect_to Meta attribute.
"""
from django.db import models
-from django.utils import six
class Question(models.Model):
@@ -18,7 +17,7 @@ class Answer(models.Model):
order_with_respect_to = 'question'
def __str__(self):
- return six.text_type(self.text)
+ return self.text
class Post(models.Model):
diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py
index fe967631ab..cc3a0efbc2 100644
--- a/tests/pagination/tests.py
+++ b/tests/pagination/tests.py
@@ -256,7 +256,7 @@ class ModelPaginationTests(TestCase):
def test_first_page(self):
paginator = Paginator(Article.objects.order_by('id'), 5)
p = paginator.page(1)
- self.assertEqual("<Page 1 of 2>", six.text_type(p))
+ self.assertEqual("<Page 1 of 2>", str(p))
self.assertQuerysetEqual(p.object_list, [
"<Article: Article 1>",
"<Article: Article 2>",
@@ -276,7 +276,7 @@ class ModelPaginationTests(TestCase):
def test_last_page(self):
paginator = Paginator(Article.objects.order_by('id'), 5)
p = paginator.page(2)
- self.assertEqual("<Page 2 of 2>", six.text_type(p))
+ self.assertEqual("<Page 2 of 2>", str(p))
self.assertQuerysetEqual(p.object_list, [
"<Article: Article 6>",
"<Article: Article 7>",
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py
index 126a8bc035..33456069aa 100644
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -5,7 +5,6 @@ from django.db.models import Prefetch, QuerySet
from django.db.models.query import get_prefetcher
from django.test import TestCase, override_settings
from django.test.utils import CaptureQueriesContext
-from django.utils import six
from django.utils.encoding import force_text
from .models import (
@@ -130,7 +129,7 @@ class PrefetchRelatedTests(TestCase):
"""A m2m can be followed through another m2m."""
with self.assertNumQueries(3):
qs = Author.objects.prefetch_related('books__read_by')
- lists = [[[six.text_type(r) for r in b.read_by.all()]
+ lists = [[[str(r) for r in b.read_by.all()]
for b in a.books.all()]
for a in qs]
self.assertEqual(lists, [
@@ -143,7 +142,7 @@ class PrefetchRelatedTests(TestCase):
def test_overriding_prefetch(self):
with self.assertNumQueries(3):
qs = Author.objects.prefetch_related('books', 'books__read_by')
- lists = [[[six.text_type(r) for r in b.read_by.all()]
+ lists = [[[str(r) for r in b.read_by.all()]
for b in a.books.all()]
for a in qs]
self.assertEqual(lists, [
@@ -154,7 +153,7 @@ class PrefetchRelatedTests(TestCase):
])
with self.assertNumQueries(3):
qs = Author.objects.prefetch_related('books__read_by', 'books')
- lists = [[[six.text_type(r) for r in b.read_by.all()]
+ lists = [[[str(r) for r in b.read_by.all()]
for b in a.books.all()]
for a in qs]
self.assertEqual(lists, [
@@ -171,7 +170,7 @@ class PrefetchRelatedTests(TestCase):
# Need a double
with self.assertNumQueries(3):
author = Author.objects.prefetch_related('books__read_by').get(name="Charlotte")
- lists = [[six.text_type(r) for r in b.read_by.all()] for b in author.books.all()]
+ lists = [[str(r) for r in b.read_by.all()] for b in author.books.all()]
self.assertEqual(lists, [["Amy"], ["Belinda"]]) # Poems, Jane Eyre
def test_foreign_key_then_m2m(self):
@@ -181,7 +180,7 @@ class PrefetchRelatedTests(TestCase):
"""
with self.assertNumQueries(2):
qs = Author.objects.select_related('first_book').prefetch_related('first_book__read_by')
- lists = [[six.text_type(r) for r in a.first_book.read_by.all()]
+ lists = [[str(r) for r in a.first_book.read_by.all()]
for a in qs]
self.assertEqual(lists, [["Amy"], ["Amy"], ["Amy"], ["Amy", "Belinda"]])
@@ -758,7 +757,7 @@ class DefaultManagerTests(TestCase):
# qualifications, since this will do one query per teacher.
qs = Department.objects.prefetch_related('teachers')
depts = "".join("%s department: %s\n" %
- (dept.name, ", ".join(six.text_type(t) for t in dept.teachers.all()))
+ (dept.name, ", ".join(str(t) for t in dept.teachers.all()))
for dept in qs)
self.assertEqual(depts,
@@ -895,8 +894,8 @@ class MultiTableInheritanceTest(TestCase):
def test_foreignkey(self):
with self.assertNumQueries(2):
qs = AuthorWithAge.objects.prefetch_related('addresses')
- addresses = [[six.text_type(address) for address in obj.addresses.all()] for obj in qs]
- self.assertEqual(addresses, [[six.text_type(self.author_address)], [], []])
+ addresses = [[str(address) for address in obj.addresses.all()] for obj in qs]
+ self.assertEqual(addresses, [[str(self.author_address)], [], []])
def test_foreignkey_to_inherited(self):
with self.assertNumQueries(2):
@@ -907,16 +906,16 @@ class MultiTableInheritanceTest(TestCase):
def test_m2m_to_inheriting_model(self):
qs = AuthorWithAge.objects.prefetch_related('books_with_year')
with self.assertNumQueries(2):
- lst = [[six.text_type(book) for book in author.books_with_year.all()] for author in qs]
+ lst = [[str(book) for book in author.books_with_year.all()] for author in qs]
qs = AuthorWithAge.objects.all()
- lst2 = [[six.text_type(book) for book in author.books_with_year.all()] for author in qs]
+ lst2 = [[str(book) for book in author.books_with_year.all()] for author in qs]
self.assertEqual(lst, lst2)
qs = BookWithYear.objects.prefetch_related('aged_authors')
with self.assertNumQueries(2):
- lst = [[six.text_type(author) for author in book.aged_authors.all()] for book in qs]
+ lst = [[str(author) for author in book.aged_authors.all()] for book in qs]
qs = BookWithYear.objects.all()
- lst2 = [[six.text_type(author) for author in book.aged_authors.all()] for book in qs]
+ lst2 = [[str(author) for author in book.aged_authors.all()] for book in qs]
self.assertEqual(lst, lst2)
def test_parent_link_prefetch(self):
@@ -953,23 +952,23 @@ class ForeignKeyToFieldTest(TestCase):
def test_foreignkey(self):
with self.assertNumQueries(2):
qs = Author.objects.prefetch_related('addresses')
- addresses = [[six.text_type(address) for address in obj.addresses.all()]
+ addresses = [[str(address) for address in obj.addresses.all()]
for obj in qs]
- self.assertEqual(addresses, [[six.text_type(self.author_address)], [], []])
+ self.assertEqual(addresses, [[str(self.author_address)], [], []])
def test_m2m(self):
with self.assertNumQueries(3):
qs = Author.objects.all().prefetch_related('favorite_authors', 'favors_me')
favorites = [(
- [six.text_type(i_like) for i_like in author.favorite_authors.all()],
- [six.text_type(likes_me) for likes_me in author.favors_me.all()]
+ [str(i_like) for i_like in author.favorite_authors.all()],
+ [str(likes_me) for likes_me in author.favors_me.all()]
) for author in qs]
self.assertEqual(
favorites,
[
- ([six.text_type(self.author2)], [six.text_type(self.author3)]),
- ([six.text_type(self.author3)], [six.text_type(self.author1)]),
- ([six.text_type(self.author1)], [six.text_type(self.author2)])
+ ([str(self.author2)], [str(self.author3)]),
+ ([str(self.author3)], [str(self.author1)]),
+ ([str(self.author1)], [str(self.author2)])
]
)
diff --git a/tests/queries/models.py b/tests/queries/models.py
index 4d5ed14ff0..8c20e76dee 100644
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -4,7 +4,6 @@ Various complex queries that have been problematic in the past.
import threading
from django.db import models
-from django.utils import six
class DumbCategory(models.Model):
@@ -142,7 +141,7 @@ class Number(models.Model):
num = models.IntegerField()
def __str__(self):
- return six.text_type(self.num)
+ return str(self.num)
# Symmetrical m2m field with a normal field using the reverse accessor name
# ("valid").
diff --git a/tests/redirects_tests/tests.py b/tests/redirects_tests/tests.py
index 29c88bd1df..558bbaaf7e 100644
--- a/tests/redirects_tests/tests.py
+++ b/tests/redirects_tests/tests.py
@@ -5,7 +5,6 @@ from django.contrib.redirects.models import Redirect
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, modify_settings, override_settings
-from django.utils import six
@modify_settings(MIDDLEWARE={'append': 'django.contrib.redirects.middleware.RedirectFallbackMiddleware'})
@@ -17,7 +16,7 @@ class RedirectTests(TestCase):
def test_model(self):
r1 = Redirect.objects.create(site=self.site, old_path='/initial', new_path='/new_target')
- self.assertEqual(six.text_type(r1), "/initial ---> /new_target")
+ self.assertEqual(str(r1), "/initial ---> /new_target")
def test_redirect(self):
Redirect.objects.create(site=self.site, old_path='/initial', new_path='/new_target')
diff --git a/tests/resolve_url/tests.py b/tests/resolve_url/tests.py
index 73556a93be..5a90282afa 100644
--- a/tests/resolve_url/tests.py
+++ b/tests/resolve_url/tests.py
@@ -1,7 +1,6 @@
from django.shortcuts import resolve_url
from django.test import SimpleTestCase, override_settings
from django.urls import NoReverseMatch, reverse_lazy
-from django.utils import six
from .models import UnimportantThing
from .urls import some_view
@@ -57,7 +56,7 @@ class ResolveUrlTests(SimpleTestCase):
string.
"""
resolved_url = resolve_url(reverse_lazy('some-view'))
- self.assertIsInstance(resolved_url, six.text_type)
+ self.assertIsInstance(resolved_url, str)
self.assertEqual('/some-url/', resolved_url)
def test_valid_view_name(self):
diff --git a/tests/runtests.py b/tests/runtests.py
index 82cd8207ba..6e86bf7a93 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -17,7 +17,6 @@ from django.test import TestCase, TransactionTestCase
from django.test.runner import default_test_processes
from django.test.selenium import SeleniumTestCaseBase
from django.test.utils import get_runner
-from django.utils import six
from django.utils._os import upath
from django.utils.deprecation import (
RemovedInDjango21Warning, RemovedInDjango30Warning,
@@ -42,10 +41,8 @@ TMPDIR = tempfile.mkdtemp(prefix='django_')
# so that children processes inherit it.
tempfile.tempdir = os.environ['TMPDIR'] = TMPDIR
-# Removing the temporary TMPDIR. Ensure we pass in unicode so that it will
-# successfully remove temp trees containing non-ASCII filenames on Windows.
-# (We're assuming the temp dir name itself only contains ASCII characters.)
-atexit.register(shutil.rmtree, six.text_type(TMPDIR))
+# Removing the temporary TMPDIR.
+atexit.register(shutil.rmtree, TMPDIR)
SUBDIRS_TO_SKIP = [
diff --git a/tests/save_delete_hooks/tests.py b/tests/save_delete_hooks/tests.py
index e0cb2f51ab..874cb7eb72 100644
--- a/tests/save_delete_hooks/tests.py
+++ b/tests/save_delete_hooks/tests.py
@@ -1,5 +1,4 @@
from django.test import TestCase
-from django.utils import six
from .models import Person
@@ -18,7 +17,7 @@ class SaveDeleteHookTests(TestCase):
Person.objects.all(), [
"John Smith",
],
- six.text_type
+ str
)
p.delete()
diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py
index bb5f7774a3..753114a6d2 100644
--- a/tests/select_related_regress/tests.py
+++ b/tests/select_related_regress/tests.py
@@ -1,5 +1,4 @@
from django.test import TestCase
-from django.utils import six
from .models import (
A, B, Building, C, Chick, Child, Class, Client, ClientStatus, Connection,
@@ -35,7 +34,7 @@ class SelectRelatedRegressTests(TestCase):
connections = Connection.objects.filter(start__device__building=b, end__device__building=b).order_by('id')
self.assertEqual(
- [(c.id, six.text_type(c.start), six.text_type(c.end)) for c in connections],
+ [(c.id, str(c.start), str(c.end)) for c in connections],
[(c1.id, 'router/4', 'switch/7'), (c2.id, 'switch/7', 'server/1')]
)
@@ -46,7 +45,7 @@ class SelectRelatedRegressTests(TestCase):
.order_by('id')
)
self.assertEqual(
- [(c.id, six.text_type(c.start), six.text_type(c.end)) for c in connections],
+ [(c.id, str(c.start), str(c.end)) for c in connections],
[(c1.id, 'router/4', 'switch/7'), (c2.id, 'switch/7', 'server/1')]
)
diff --git a/tests/serializers/models/base.py b/tests/serializers/models/base.py
index aa55b87c61..9421578478 100644
--- a/tests/serializers/models/base.py
+++ b/tests/serializers/models/base.py
@@ -7,7 +7,6 @@ Serialization
from decimal import Decimal
from django.db import models
-from django.utils import six
class CategoryMetaDataManager(models.Manager):
@@ -118,7 +117,7 @@ class TeamField(models.CharField):
super(TeamField, self).__init__(max_length=100)
def get_db_prep_save(self, value, connection):
- return six.text_type(value.title)
+ return str(value.title)
def to_python(self, value):
if isinstance(value, Team):
diff --git a/tests/serializers/test_xml.py b/tests/serializers/test_xml.py
index 71b38d48fa..ea9677d87f 100644
--- a/tests/serializers/test_xml.py
+++ b/tests/serializers/test_xml.py
@@ -3,7 +3,6 @@ from xml.dom import minidom
from django.core import serializers
from django.core.serializers.xml_serializer import DTDForbidden
from django.test import TestCase, TransactionTestCase
-from django.utils import six
from .tests import SerializersTestBase, SerializersTransactionTestBase
@@ -34,7 +33,7 @@ class XmlSerializerTestCase(SerializersTestBase, TestCase):
def _comparison_value(value):
# The XML serializer handles everything as strings, so comparisons
# need to be performed on the stringified value
- return six.text_type(value)
+ return str(value)
@staticmethod
def _validate_output(serial_str):
diff --git a/tests/serializers/test_yaml.py b/tests/serializers/test_yaml.py
index 038227efea..f3988d7ff1 100644
--- a/tests/serializers/test_yaml.py
+++ b/tests/serializers/test_yaml.py
@@ -4,7 +4,6 @@ import unittest
from django.core import management, serializers
from django.core.serializers.base import DeserializationError
from django.test import SimpleTestCase, TestCase, TransactionTestCase
-from django.utils import six
from django.utils.six import StringIO
from .models import Author
@@ -147,7 +146,7 @@ class YamlSerializerTestCase(SerializersTestBase, TestCase):
# yaml.safe_load will return non-string objects for some
# of the fields we are interested in, this ensures that
# everything comes back as a string
- if isinstance(field_value, six.string_types):
+ if isinstance(field_value, str):
ret_list.append(field_value)
else:
ret_list.append(str(field_value))
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index ff1d4aff8c..ee0d8629cf 100644
--- a/tests/servers/tests.py
+++ b/tests/servers/tests.py
@@ -9,7 +9,6 @@ import socket
from django.test import LiveServerTestCase, override_settings
from django.utils._os import upath
from django.utils.http import urlencode
-from django.utils.six import text_type
from django.utils.six.moves.urllib.error import HTTPError
from django.utils.six.moves.urllib.request import urlopen
@@ -48,7 +47,7 @@ class LiveServerAddress(LiveServerBase):
cls.live_server_url_test = [cls.live_server_url]
def test_live_server_url_is_class_property(self):
- self.assertIsInstance(self.live_server_url_test[0], text_type)
+ self.assertIsInstance(self.live_server_url_test[0], str)
self.assertEqual(self.live_server_url_test[0], self.live_server_url)
diff --git a/tests/signals/tests.py b/tests/signals/tests.py
index 9cb470b8cf..88572ad44f 100644
--- a/tests/signals/tests.py
+++ b/tests/signals/tests.py
@@ -4,7 +4,6 @@ from django.db.models import signals
from django.dispatch import receiver
from django.test import TestCase, mock
from django.test.utils import isolate_apps
-from django.utils import six
from .models import Author, Book, Car, Person
@@ -160,7 +159,7 @@ class SignalTests(BaseSignalTest):
Person.objects.all(), [
"James Jones",
],
- six.text_type
+ str
)
finally:
signals.pre_delete.disconnect(pre_delete_handler)
diff --git a/tests/staticfiles_tests/cases.py b/tests/staticfiles_tests/cases.py
index f278e6a974..069402c6f6 100644
--- a/tests/staticfiles_tests/cases.py
+++ b/tests/staticfiles_tests/cases.py
@@ -7,7 +7,6 @@ from django.conf import settings
from django.core.management import call_command
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings
-from django.utils import six
from django.utils.encoding import force_text
from .settings import TEST_SETTINGS
@@ -30,7 +29,7 @@ class BaseStaticFilesMixin(object):
self._get_file(filepath)
def render_template(self, template, **kwargs):
- if isinstance(template, six.string_types):
+ if isinstance(template, str):
template = Template(template)
return template.render(Context(**kwargs)).strip()
@@ -72,7 +71,7 @@ class CollectionTestCase(BaseStaticFilesMixin, SimpleTestCase):
self.patched_settings.enable()
self.run_collectstatic()
# Same comment as in runtests.teardown.
- self.addCleanup(shutil.rmtree, six.text_type(temp_dir))
+ self.addCleanup(shutil.rmtree, temp_dir)
def tearDown(self):
self.patched_settings.disable()
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index e8c00eb3f5..7d17f2abe1 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -166,7 +166,7 @@ class TestCollectionClear(CollectionTestCase):
self.assertFileNotFound('cleared.txt')
def test_dir_not_exists(self, **kwargs):
- shutil.rmtree(six.text_type(settings.STATIC_ROOT))
+ shutil.rmtree(settings.STATIC_ROOT)
super(TestCollectionClear, self).run_collectstatic(clear=True)
@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.PathNotImplementedStorage')
@@ -210,7 +210,7 @@ class TestInteractiveMessages(CollectionTestCase):
def test_no_warning_when_staticdir_does_not_exist(self):
stdout = six.StringIO()
- shutil.rmtree(six.text_type(settings.STATIC_ROOT))
+ shutil.rmtree(settings.STATIC_ROOT)
call_command('collectstatic', interactive=True, stdout=stdout)
output = force_text(stdout.getvalue())
self.assertNotIn(self.overwrite_warning_msg, output)
@@ -222,7 +222,7 @@ class TestInteractiveMessages(CollectionTestCase):
static_dir = tempfile.mkdtemp(prefix='collectstatic_empty_staticdir_test')
with override_settings(STATIC_ROOT=static_dir):
call_command('collectstatic', interactive=True, stdout=stdout)
- shutil.rmtree(six.text_type(static_dir))
+ shutil.rmtree(static_dir)
output = force_text(stdout.getvalue())
self.assertNotIn(self.overwrite_warning_msg, output)
self.assertNotIn(self.delete_warning_msg, output)
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py
index d1b7a49626..6333be7549 100644
--- a/tests/staticfiles_tests/test_storage.py
+++ b/tests/staticfiles_tests/test_storage.py
@@ -350,7 +350,7 @@ class TestCollectionManifestStorage(TestHashedFiles, CollectionTestCase):
self.patched_settings = self.settings(
STATICFILES_DIRS=settings.STATICFILES_DIRS + [temp_dir])
self.patched_settings.enable()
- self.addCleanup(shutil.rmtree, six.text_type(temp_dir))
+ self.addCleanup(shutil.rmtree, temp_dir)
self._manifest_strict = storage.staticfiles_storage.manifest_strict
def tearDown(self):
diff --git a/tests/template_tests/filter_tests/test_escape.py b/tests/template_tests/filter_tests/test_escape.py
index 6f28b972a2..22d5ca7d55 100644
--- a/tests/template_tests/filter_tests/test_escape.py
+++ b/tests/template_tests/filter_tests/test_escape.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import escape
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.functional import Promise, lazy
from django.utils.safestring import mark_safe
@@ -34,7 +33,7 @@ class EscapeTests(SimpleTestCase):
self.assertEqual(output, "x&amp;y")
def test_escape_lazy_string(self):
- add_html = lazy(lambda string: string + 'special characters > here', six.text_type)
+ add_html = lazy(lambda string: string + 'special characters > here', str)
escaped = escape(add_html('<some html & '))
self.assertIsInstance(escaped, Promise)
self.assertEqual(escaped, '&lt;some html &amp; special characters &gt; here')
diff --git a/tests/template_tests/filter_tests/test_escapejs.py b/tests/template_tests/filter_tests/test_escapejs.py
index 3b038726b2..9aa98819e1 100644
--- a/tests/template_tests/filter_tests/test_escapejs.py
+++ b/tests/template_tests/filter_tests/test_escapejs.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import escapejs_filter
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.functional import lazy
from ..utils import setup
@@ -53,7 +52,7 @@ class FunctionTests(SimpleTestCase):
)
def test_lazy_string(self):
- append_script = lazy(lambda string: r'<script>this</script>' + string, six.text_type)
+ append_script = lazy(lambda string: r'<script>this</script>' + string, str)
self.assertEqual(
escapejs_filter(append_script('whitespace: \r\n\t\v\f\b')),
'\\u003Cscript\\u003Ethis\\u003C/script\\u003E'
diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
index d4a4526d1d..8474238f21 100644
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -2,7 +2,6 @@ from decimal import Decimal, localcontext
from django.template.defaultfilters import floatformat
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.safestring import mark_safe
from ..utils import setup
@@ -64,13 +63,13 @@ class FunctionTests(SimpleTestCase):
def test_infinity(self):
pos_inf = float(1e30000)
- self.assertEqual(floatformat(pos_inf), six.text_type(pos_inf))
+ self.assertEqual(floatformat(pos_inf), str(pos_inf))
neg_inf = float(-1e30000)
- self.assertEqual(floatformat(neg_inf), six.text_type(neg_inf))
+ self.assertEqual(floatformat(neg_inf), str(neg_inf))
nan = pos_inf / pos_inf
- self.assertEqual(floatformat(nan), six.text_type(nan))
+ self.assertEqual(floatformat(nan), str(nan))
def test_float_dunder_method(self):
class FloatWrapper(object):
diff --git a/tests/template_tests/filter_tests/test_linebreaks.py b/tests/template_tests/filter_tests/test_linebreaks.py
index 50a66f3c47..0f3cd7a117 100644
--- a/tests/template_tests/filter_tests/test_linebreaks.py
+++ b/tests/template_tests/filter_tests/test_linebreaks.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import linebreaks_filter
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
@@ -54,7 +53,7 @@ class FunctionTests(SimpleTestCase):
)
def test_lazy_string_input(self):
- add_header = lazy(lambda string: 'Header\n\n' + string, six.text_type)
+ add_header = lazy(lambda string: 'Header\n\n' + string, str)
self.assertEqual(
linebreaks_filter(add_header('line 1\r\nline2')),
'<p>Header</p>\n\n<p>line 1<br />line2</p>'
diff --git a/tests/template_tests/filter_tests/test_slugify.py b/tests/template_tests/filter_tests/test_slugify.py
index ec9f2bb736..cb23e9b320 100644
--- a/tests/template_tests/filter_tests/test_slugify.py
+++ b/tests/template_tests/filter_tests/test_slugify.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import slugify
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.encoding import force_text
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
@@ -43,7 +42,7 @@ class FunctionTests(SimpleTestCase):
self.assertEqual(slugify(123), '123')
def test_slugify_lazy_string(self):
- lazy_str = lazy(lambda string: force_text(string), six.text_type)
+ lazy_str = lazy(lambda string: force_text(string), str)
self.assertEqual(
slugify(lazy_str(' Jack & Jill like numbers 1,2,3 and 4 and silly characters ?%.$!/')),
'jack-jill-like-numbers-123-and-4-and-silly-characters',
diff --git a/tests/template_tests/filter_tests/test_urlize.py b/tests/template_tests/filter_tests/test_urlize.py
index 3096213a22..2bf94126d4 100644
--- a/tests/template_tests/filter_tests/test_urlize.py
+++ b/tests/template_tests/filter_tests/test_urlize.py
@@ -1,6 +1,5 @@
from django.template.defaultfilters import urlize
from django.test import SimpleTestCase
-from django.utils import six
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
@@ -367,7 +366,7 @@ class FunctionTests(SimpleTestCase):
)
def test_lazystring(self):
- prepend_www = lazy(lambda url: 'www.' + url, six.text_type)
+ prepend_www = lazy(lambda url: 'www.' + url, str)
self.assertEqual(
urlize(prepend_www('google.com')),
'<a href="http://www.google.com" rel="nofollow">www.google.com</a>',
diff --git a/tests/template_tests/templatetags/custom.py b/tests/template_tests/templatetags/custom.py
index 3c3e4ce8ed..363e7094ce 100644
--- a/tests/template_tests/templatetags/custom.py
+++ b/tests/template_tests/templatetags/custom.py
@@ -94,7 +94,7 @@ simple_one_default.anything = "Expected simple_one_default __dict__"
def simple_unlimited_args(one, two='hi', *args):
"""Expected simple_unlimited_args __doc__"""
return "simple_unlimited_args - Expected result: %s" % (
- ', '.join(six.text_type(arg) for arg in [one, two] + list(args))
+ ', '.join(str(arg) for arg in [one, two] + list(args))
)
@@ -104,7 +104,7 @@ simple_unlimited_args.anything = "Expected simple_unlimited_args __dict__"
@register.simple_tag
def simple_only_unlimited_args(*args):
"""Expected simple_only_unlimited_args __doc__"""
- return "simple_only_unlimited_args - Expected result: %s" % ', '.join(six.text_type(arg) for arg in args)
+ return "simple_only_unlimited_args - Expected result: %s" % ', '.join(str(arg) for arg in args)
simple_only_unlimited_args.anything = "Expected simple_only_unlimited_args __dict__"
@@ -116,7 +116,7 @@ def simple_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
# Sort the dictionary by key to guarantee the order for testing.
sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
return "simple_unlimited_args_kwargs - Expected result: %s / %s" % (
- ', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
+ ', '.join(str(arg) for arg in [one, two] + list(args)),
', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
)
diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py
index dbdfa45c95..745dd7ffae 100644
--- a/tests/template_tests/templatetags/inclusion.py
+++ b/tests/template_tests/templatetags/inclusion.py
@@ -152,7 +152,7 @@ def inclusion_unlimited_args(one, two='hi', *args):
return {
"result": (
"inclusion_unlimited_args - Expected result: %s" % (
- ', '.join(six.text_type(arg) for arg in [one, two] + list(args))
+ ', '.join(str(arg) for arg in [one, two] + list(args))
)
)
}
@@ -167,7 +167,7 @@ def inclusion_unlimited_args_from_template(one, two='hi', *args):
return {
"result": (
"inclusion_unlimited_args_from_template - Expected result: %s" % (
- ', '.join(six.text_type(arg) for arg in [one, two] + list(args))
+ ', '.join(str(arg) for arg in [one, two] + list(args))
)
)
}
@@ -181,7 +181,7 @@ def inclusion_only_unlimited_args(*args):
"""Expected inclusion_only_unlimited_args __doc__"""
return {
"result": "inclusion_only_unlimited_args - Expected result: %s" % (
- ', '.join(six.text_type(arg) for arg in args)
+ ', '.join(str(arg) for arg in args)
)
}
@@ -194,7 +194,7 @@ def inclusion_only_unlimited_args_from_template(*args):
"""Expected inclusion_only_unlimited_args_from_template __doc__"""
return {
"result": "inclusion_only_unlimited_args_from_template - Expected result: %s" % (
- ', '.join(six.text_type(arg) for arg in args)
+ ', '.join(str(arg) for arg in args)
)
}
@@ -217,7 +217,7 @@ def inclusion_unlimited_args_kwargs(one, two='hi', *args, **kwargs):
# Sort the dictionary by key to guarantee the order for testing.
sorted_kwarg = sorted(six.iteritems(kwargs), key=operator.itemgetter(0))
return {"result": "inclusion_unlimited_args_kwargs - Expected result: %s / %s" % (
- ', '.join(six.text_type(arg) for arg in [one, two] + list(args)),
+ ', '.join(str(arg) for arg in [one, two] + list(args)),
', '.join('%s=%s' % (k, v) for (k, v) in sorted_kwarg)
)}
diff --git a/tests/template_tests/test_unicode.py b/tests/template_tests/test_unicode.py
index f6471e72e0..dbd18eb495 100644
--- a/tests/template_tests/test_unicode.py
+++ b/tests/template_tests/test_unicode.py
@@ -2,7 +2,6 @@ from unittest import TestCase
from django.template import Context, Engine
from django.template.base import TemplateEncodingError
-from django.utils import six
from django.utils.safestring import SafeData
@@ -28,5 +27,5 @@ class UnicodeTests(TestCase):
# they all render the same (and are returned as unicode objects and
# "safe" objects as well, for auto-escaping purposes).
self.assertEqual(t1.render(c3), t2.render(c3))
- self.assertIsInstance(t1.render(c3), six.text_type)
+ self.assertIsInstance(t1.render(c3), str)
self.assertIsInstance(t1.render(c3), SafeData)
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index e63c6774ae..4d29f1a491 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -226,7 +226,7 @@ class AssertQuerysetEqualTests(TestCase):
class CaptureQueriesContextManagerTests(TestCase):
def setUp(self):
- self.person_pk = six.text_type(Person.objects.create(name='test').pk)
+ self.person_pk = str(Person.objects.create(name='test').pk)
def test_simple(self):
with CaptureQueriesContext(connection) as captured_queries:
diff --git a/tests/update/models.py b/tests/update/models.py
index 1fbab38ca9..bfcc29bee9 100644
--- a/tests/update/models.py
+++ b/tests/update/models.py
@@ -4,7 +4,6 @@ updates.
"""
from django.db import models
-from django.utils import six
class DataPoint(models.Model):
@@ -13,7 +12,7 @@ class DataPoint(models.Model):
another_value = models.CharField(max_length=20, blank=True)
def __str__(self):
- return six.text_type(self.name)
+ return self.name
class RelatedPoint(models.Model):
@@ -21,7 +20,7 @@ class RelatedPoint(models.Model):
data = models.ForeignKey(DataPoint, models.CASCADE)
def __str__(self):
- return six.text_type(self.name)
+ return self.name
class A(models.Model):
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index 157479a579..62d199c030 100644
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -20,7 +20,6 @@ from django.urls import (
NoReverseMatch, RegexURLPattern, RegexURLResolver, Resolver404,
ResolverMatch, get_callable, get_resolver, resolve, reverse, reverse_lazy,
)
-from django.utils import six
from . import middleware, urlconf_outer, views
from .utils import URLObject
@@ -336,13 +335,6 @@ class URLPatternReverse(SimpleTestCase):
'/script:name/optional/foo:bar/'
)
- def test_reverse_returns_unicode(self):
- name, expected, args, kwargs = test_data[0]
- self.assertIsInstance(
- reverse(name, args=args, kwargs=kwargs),
- six.text_type
- )
-
def test_view_not_found_message(self):
msg = (
"Reverse for 'non-existent-view' not found. 'non-existent-view' "
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py
index b4e7b9c0ac..faf30a59c0 100644
--- a/tests/utils_tests/test_encoding.py
+++ b/tests/utils_tests/test_encoding.py
@@ -1,7 +1,6 @@
import datetime
import unittest
-from django.utils import six
from django.utils.encoding import (
escape_uri_path, filepath_to_uri, force_bytes, force_text, iri_to_uri,
smart_text, uri_to_iri,
@@ -27,7 +26,7 @@ class TestEncodingUtils(unittest.TestCase):
def test_force_text_lazy(self):
s = SimpleLazyObject(lambda: 'x')
- self.assertTrue(issubclass(type(force_text(s)), six.text_type))
+ self.assertTrue(issubclass(type(force_text(s)), str))
def test_force_bytes_exception(self):
"""
diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py
index 0ca534445f..f53e212f93 100644
--- a/tests/utils_tests/test_functional.py
+++ b/tests/utils_tests/test_functional.py
@@ -1,6 +1,5 @@
import unittest
-from django.utils import six
from django.utils.functional import cached_property, lazy
@@ -45,8 +44,8 @@ class FunctionalTestCase(unittest.TestCase):
return b"\xc3\x8e am \xc4\x81 binary \xc7\xa8l\xc3\xa2zz."
t = lazy(lambda: Klazz(), Klazz)()
- self.assertEqual(six.text_type(t), "Î am ā Ǩlâzz.")
- self.assertEqual(six.binary_type(t), b"\xc3\x8e am \xc4\x81 binary \xc7\xa8l\xc3\xa2zz.")
+ self.assertEqual(str(t), "Î am ā Ǩlâzz.")
+ self.assertEqual(bytes(t), b"\xc3\x8e am \xc4\x81 binary \xc7\xa8l\xc3\xa2zz.")
def test_cached_property(self):
"""
@@ -99,7 +98,7 @@ class FunctionalTestCase(unittest.TestCase):
def test_lazy_repr_text(self):
original_object = 'Lazy translation text'
- lazy_obj = lazy(lambda: original_object, six.text_type)
+ lazy_obj = lazy(lambda: original_object, str)
self.assertEqual(repr(original_object), repr(lazy_obj()))
def test_lazy_repr_int(self):
diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py
index 588e85afc5..8c9b997b3c 100644
--- a/tests/utils_tests/test_lazyobject.py
+++ b/tests/utils_tests/test_lazyobject.py
@@ -73,7 +73,7 @@ class LazyObjectTestCase(TestCase):
def test_text(self):
obj = self.lazy_wrap('foo')
- self.assertEqual(six.text_type(obj), 'foo')
+ self.assertEqual(str(obj), 'foo')
def test_bool(self):
# Refs #21840
diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py
index 96f42d5ddd..9e99b6e20b 100644
--- a/tests/utils_tests/test_safestring.py
+++ b/tests/utils_tests/test_safestring.py
@@ -1,6 +1,6 @@
from django.template import Context, Template
from django.test import SimpleTestCase
-from django.utils import html, six, text
+from django.utils import html, text
from django.utils.encoding import force_bytes
from django.utils.functional import lazy, lazystr
from django.utils.safestring import SafeData, mark_safe
@@ -8,7 +8,7 @@ from django.utils.safestring import SafeData, mark_safe
lazybytes = lazy(force_bytes, bytes)
-class customescape(six.text_type):
+class customescape(str):
def __html__(self):
# implement specific and obviously wrong escaping
# in order to be able to tell for sure when it runs
diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py
index 9128fb0247..22695277a4 100644
--- a/tests/utils_tests/test_text.py
+++ b/tests/utils_tests/test_text.py
@@ -1,7 +1,7 @@
import json
from django.test import SimpleTestCase
-from django.utils import six, text
+from django.utils import text
from django.utils.functional import lazystr
from django.utils.text import format_lazy
from django.utils.translation import override, ugettext_lazy
@@ -161,7 +161,6 @@ class TestUtilsText(SimpleTestCase):
"""normalize_newlines should be able to handle bytes too"""
normalized = text.normalize_newlines(b"abc\ndef\rghi\r\n")
self.assertEqual(normalized, "abc\ndef\nghi\n")
- self.assertIsInstance(normalized, six.text_type)
def test_phone2numeric(self):
numeric = text.phone2numeric('0800 flowers')