1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Refs #23919 -- Removed most of remaining six usage

Thanks Tim Graham for the review.
This commit is contained in:
Claude Paroz
2017-01-07 12:11:46 +01:00
parent 7b2f2e74ad
commit 2b281cc35e
180 changed files with 421 additions and 559 deletions

View File

@@ -3,6 +3,7 @@ import sys
import tempfile
import unittest
import warnings
from io import StringIO
from django.apps import apps
from django.contrib.sites.models import Site
@@ -15,7 +16,6 @@ from django.db import IntegrityError, connection
from django.test import (
TestCase, TransactionTestCase, mock, skipUnlessDBFeature,
)
from django.utils import six
from django.utils.encoding import force_text
from .models import (
@@ -52,7 +52,7 @@ class DumpDataAssertMixin(object):
def _dumpdata_assert(self, args, output, format='json', filename=None,
natural_foreign_keys=False, natural_primary_keys=False,
use_base_manager=False, exclude_list=[], primary_keys=''):
new_io = six.StringIO()
new_io = StringIO()
if filename:
filename = os.path.join(tempfile.gettempdir(), filename)
management.call_command('dumpdata', *args, **{'format': format,
@@ -445,7 +445,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
def test_dumpdata_with_uuid_pks(self):
m1 = PrimaryKeyUUIDModel.objects.create()
m2 = PrimaryKeyUUIDModel.objects.create()
output = six.StringIO()
output = StringIO()
management.call_command(
'dumpdata', 'fixtures.PrimaryKeyUUIDModel', '--pks', ', '.join([str(m1.id), str(m2.id)]),
stdout=output,
@@ -471,7 +471,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
stdout is a tty, and verbosity > 0.
"""
management.call_command('loaddata', 'fixture1.json', verbosity=0)
new_io = six.StringIO()
new_io = StringIO()
new_io.isatty = lambda: True
with NamedTemporaryFile() as file:
options = {
@@ -485,7 +485,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
# Test no progress bar when verbosity = 0
options['verbosity'] = 0
new_io = six.StringIO()
new_io = StringIO()
new_io.isatty = lambda: True
options.update({'stdout': new_io, 'stderr': new_io})
management.call_command('dumpdata', 'fixtures', **options)
@@ -583,7 +583,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
])
def test_loaddata_verbosity_three(self):
output = six.StringIO()
output = StringIO()
management.call_command('loaddata', 'fixture1.json', verbosity=3, stdout=output, stderr=output)
command_output = force_text(output.getvalue())
self.assertIn(
@@ -689,7 +689,7 @@ class NonExistentFixtureTests(TestCase):
"""
def test_loaddata_not_existent_fixture_file(self):
stdout_output = six.StringIO()
stdout_output = StringIO()
with self.assertRaisesMessage(CommandError, "No fixture named 'this_fixture_doesnt_exist' found."):
management.call_command('loaddata', 'this_fixture_doesnt_exist', stdout=stdout_output)