mirror of https://github.com/django/django.git
[py3] Used compatible imports of StringIO.
This commit is contained in:
parent
2da3af23aa
commit
396357741b
|
@ -1,11 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import StringIO
|
||||
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import management
|
||||
from django.db import connection, IntegrityError
|
||||
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from .models import Article, Book, Spy, Tag, Visa
|
||||
|
||||
|
@ -26,7 +25,7 @@ class FixtureLoadingTests(TestCase):
|
|||
|
||||
def _dumpdata_assert(self, args, output, format='json', natural_keys=False,
|
||||
use_base_manager=False, exclude_list=[]):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
management.call_command('dumpdata', *args, **{'format':format,
|
||||
'stdout':new_io,
|
||||
'stderr':new_io,
|
||||
|
@ -43,7 +42,7 @@ class FixtureLoadingTests(TestCase):
|
|||
])
|
||||
|
||||
def test_loading_and_dumping(self):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
|
||||
Site.objects.all().delete()
|
||||
# Load fixture 1. Single JSON file, with two objects.
|
||||
|
@ -293,7 +292,7 @@ class FixtureLoadingTests(TestCase):
|
|||
|
||||
class FixtureTransactionTests(TransactionTestCase):
|
||||
def _dumpdata_assert(self, args, output, format='json'):
|
||||
new_io = StringIO.StringIO()
|
||||
new_io = StringIO()
|
||||
management.call_command('dumpdata', *args, **{'format':format, 'stdout':new_io})
|
||||
command_output = new_io.getvalue().strip()
|
||||
self.assertEqual(command_output, output)
|
||||
|
|
|
@ -4,13 +4,13 @@ from __future__ import absolute_import, unicode_literals
|
|||
import json
|
||||
from datetime import datetime
|
||||
from xml.dom import minidom
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import serializers
|
||||
from django.db import transaction, connection
|
||||
from django.test import TestCase, TransactionTestCase, Approximate
|
||||
from django.utils import six
|
||||
from django.utils.six import StringIO
|
||||
from django.utils import unittest
|
||||
|
||||
from .models import (Category, Author, Article, AuthorProfile, Actor, Movie,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import sys
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.core import management
|
||||
from django.core.management.base import CommandError
|
||||
from django.test import TestCase
|
||||
from django.utils import translation
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
class CommandTests(TestCase):
|
||||
|
|
|
@ -3,11 +3,11 @@ A series of tests to establish that the command-line bash completion works.
|
|||
"""
|
||||
import os
|
||||
import sys
|
||||
import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management import ManagementUtility
|
||||
from django.utils import unittest
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
class BashCompletionTests(unittest.TestCase):
|
||||
|
@ -20,7 +20,7 @@ class BashCompletionTests(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.old_DJANGO_AUTO_COMPLETE = os.environ.get('DJANGO_AUTO_COMPLETE')
|
||||
os.environ['DJANGO_AUTO_COMPLETE'] = '1'
|
||||
self.output = StringIO.StringIO()
|
||||
self.output = StringIO()
|
||||
self.old_stdout = sys.stdout
|
||||
sys.stdout = self.output
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from StringIO import StringIO
|
||||
|
||||
from django.core.servers.basehttp import ServerHandler
|
||||
from django.utils.six import StringIO
|
||||
from django.utils.unittest import TestCase
|
||||
|
||||
#
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from StringIO import StringIO
|
||||
|
||||
from django.contrib.auth import models
|
||||
from django.contrib.auth.management.commands import changepassword
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
class MultiDBChangepasswordManagementCommandTestCase(TestCase):
|
||||
|
|
|
@ -7,12 +7,12 @@ import hashlib
|
|||
import json
|
||||
import os
|
||||
import shutil
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.core.files import temp as tempfile
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.http.multipartparser import MultiPartParser
|
||||
from django.test import TestCase, client
|
||||
from django.utils.six import StringIO
|
||||
from django.utils import unittest
|
||||
|
||||
from . import uploadhandler
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
import os
|
||||
import re
|
||||
import shutil
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.core import management
|
||||
from django.test import TestCase
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
LOCALE='de'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from StringIO import StringIO
|
||||
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
class InspectDBTestCase(TestCase):
|
||||
|
|
|
@ -7,7 +7,6 @@ import os
|
|||
import shutil
|
||||
import smtpd
|
||||
import sys
|
||||
from StringIO import StringIO
|
||||
import tempfile
|
||||
import threading
|
||||
|
||||
|
@ -18,6 +17,7 @@ from django.core.mail.backends import console, dummy, locmem, filebased, smtp
|
|||
from django.core.mail.message import BadHeaderError
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.six import StringIO
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import gzip
|
||||
import re
|
||||
import random
|
||||
import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
|
@ -16,6 +15,7 @@ from django.middleware.gzip import GZipMiddleware
|
|||
from django.test import TestCase, RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.utils.six.moves import xrange
|
||||
from django.utils.six import StringIO
|
||||
|
||||
class CommonMiddlewareTest(TestCase):
|
||||
def setUp(self):
|
||||
|
@ -526,7 +526,7 @@ class GZipMiddlewareTest(TestCase):
|
|||
|
||||
@staticmethod
|
||||
def decompress(gzipped_string):
|
||||
return gzip.GzipFile(mode='rb', fileobj=StringIO.StringIO(gzipped_string)).read()
|
||||
return gzip.GzipFile(mode='rb', fileobj=StringIO(gzipped_string)).read()
|
||||
|
||||
def test_compress_response(self):
|
||||
"""
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import absolute_import, unicode_literals
|
|||
|
||||
import datetime
|
||||
import pickle
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
|
@ -11,6 +10,7 @@ from django.core import management
|
|||
from django.db import connections, router, DEFAULT_DB_ALIAS
|
||||
from django.db.models import signals
|
||||
from django.test import TestCase
|
||||
from django.utils.six import StringIO
|
||||
|
||||
from .models import Book, Person, Pet, Review, UserProfile
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import unicode_literals
|
|||
import time
|
||||
import warnings
|
||||
from datetime import datetime, timedelta
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.handlers.wsgi import WSGIRequest, LimitedStream
|
||||
|
@ -11,6 +10,7 @@ from django.http import HttpRequest, HttpResponse, parse_cookie, build_request_r
|
|||
from django.test.utils import str_prefix
|
||||
from django.utils import unittest
|
||||
from django.utils.http import cookie_date
|
||||
from django.utils.six import StringIO
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ if __name__ == '__main__':
|
|||
import sys
|
||||
import pkg_resources
|
||||
import imp
|
||||
import StringIO
|
||||
import os.path
|
||||
|
||||
from django.template import TemplateDoesNotExist, Context
|
||||
from django.template.loaders.eggs import Loader as EggLoader
|
||||
from django.template import loader
|
||||
from django.utils import unittest
|
||||
from django.utils.six import StringIO
|
||||
|
||||
|
||||
# Mock classes and objects for pkg_resources functions.
|
||||
|
@ -61,8 +61,8 @@ class EggLoaderTest(unittest.TestCase):
|
|||
|
||||
self.empty_egg = create_egg("egg_empty", {})
|
||||
self.egg_1 = create_egg("egg_1", {
|
||||
os.path.normcase('templates/y.html') : StringIO.StringIO("y"),
|
||||
os.path.normcase('templates/x.txt') : StringIO.StringIO("x"),
|
||||
os.path.normcase('templates/y.html') : StringIO("y"),
|
||||
os.path.normcase('templates/x.txt') : StringIO("x"),
|
||||
})
|
||||
self._old_installed_apps = settings.INSTALLED_APPS
|
||||
settings.INSTALLED_APPS = []
|
||||
|
|
|
@ -493,7 +493,7 @@ __test__ = {"API_TEST": r"""
|
|||
# Standard doctests do fairly
|
||||
>>> import json
|
||||
>>> from django.utils.xmlutils import SimplerXMLGenerator
|
||||
>>> from StringIO import StringIO
|
||||
>>> from django.utils.six import StringIO
|
||||
|
||||
>>> def produce_long():
|
||||
... return 42L
|
||||
|
|
Loading…
Reference in New Issue