Ticket #19357: 19357-wip-2.patch

File 19357-wip-2.patch, 79.5 KB (added by Aymeric Augustin, 12 years ago)
  • django/contrib/auth/tests/context_processors.py

    diff --git a/django/contrib/auth/tests/context_processors.py b/django/contrib/auth/tests/context_processors.py
    index 32fea8a..42bed4d 100644
    a b class PermWrapperTests(TestCase):  
    6363@skipIfCustomUser
    6464@override_settings(
    6565    TEMPLATE_DIRS=(
    66             os.path.join(os.path.dirname(__file__), 'templates'),
     66            os.path.join(os.path.dirname(__file__), str('templates')),
    6767        ),
    6868    USE_TZ=False,                           # required for loading the fixture
    6969    PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
    class AuthContextProcessorTests(TestCase):  
    110110        self.assertContains(response, "Has auth permissions")
    111111        self.assertContains(response, "Has auth.add_permission permissions")
    112112        self.assertNotContains(response, "nonexisting")
    113    
     113
    114114    def test_perm_in_perms_attrs(self):
    115115        u = User.objects.create_user(username='normal', password='secret')
    116116        u.user_permissions.add(
  • django/contrib/auth/tests/forms.py

    diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
    index f3eb242..674d78e 100644
    a b class PasswordResetFormTest(TestCase):  
    322322        self.assertEqual(form.cleaned_data['email'], email)
    323323
    324324    def test_custom_email_subject(self):
    325         template_path = os.path.join(os.path.dirname(__file__), 'templates')
     325        template_path = os.path.join(os.path.dirname(__file__), str('templates'))
    326326        with self.settings(TEMPLATE_DIRS=(template_path,)):
    327327            data = {'email': 'testclient@example.com'}
    328328            form = PasswordResetForm(data)
  • django/contrib/auth/tests/views.py

    diff --git a/django/contrib/auth/tests/views.py b/django/contrib/auth/tests/views.py
    index b97d4a7..5c1e995 100644
    a b from django.contrib.auth.tests.utils import skipIfCustomUser  
    2727    LANGUAGE_CODE='en',
    2828    TEMPLATE_LOADERS=global_settings.TEMPLATE_LOADERS,
    2929    TEMPLATE_DIRS=(
    30         os.path.join(os.path.dirname(__file__), 'templates'),
     30        os.path.join(os.path.dirname(__file__), str('templates')),
    3131    ),
    3232    USE_TZ=False,
    3333    PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
  • django/contrib/flatpages/tests/csrf.py

    diff --git a/django/contrib/flatpages/tests/csrf.py b/django/contrib/flatpages/tests/csrf.py
    index e64c4bb..b1a74d9 100644
    a b from django.test.utils import override_settings  
    1616        'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    1717    ),
    1818    TEMPLATE_DIRS=(
    19         os.path.join(os.path.dirname(__file__), 'templates'),
     19        os.path.join(os.path.dirname(__file__), str('templates')),
    2020    ),
    2121    SITE_ID=1,
    2222)
  • django/contrib/flatpages/tests/middleware.py

    diff --git a/django/contrib/flatpages/tests/middleware.py b/django/contrib/flatpages/tests/middleware.py
    index 4afa4ff..588b94b 100644
    a b from django.test.utils import override_settings  
    1717        'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    1818    ),
    1919    TEMPLATE_DIRS=(
    20         os.path.join(os.path.dirname(__file__), 'templates'),
     20        os.path.join(os.path.dirname(__file__), str('templates')),
    2121    ),
    2222    SITE_ID=1,
    2323)
    class FlatpageMiddlewareTests(TestCase):  
    9595        'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    9696    ),
    9797    TEMPLATE_DIRS=(
    98         os.path.join(os.path.dirname(__file__), 'templates'),
     98        os.path.join(os.path.dirname(__file__), str('templates')),
    9999    ),
    100100    SITE_ID=1,
    101101)
  • django/contrib/flatpages/tests/templatetags.py

    diff --git a/django/contrib/flatpages/tests/templatetags.py b/django/contrib/flatpages/tests/templatetags.py
    index aebc622..2fe2263 100644
    a b from django.test.utils import override_settings  
    1616        'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
    1717    ),
    1818    TEMPLATE_DIRS=(
    19         os.path.join(os.path.dirname(__file__), 'templates'),
     19        os.path.join(os.path.dirname(__file__), str('templates')),
    2020    ),
    2121    SITE_ID=1,
    2222)
  • django/contrib/flatpages/tests/views.py

    diff --git a/django/contrib/flatpages/tests/views.py b/django/contrib/flatpages/tests/views.py
    index b69bd6a..88204ae 100644
    a b from django.test.utils import override_settings  
    1717        # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
    1818    ),
    1919    TEMPLATE_DIRS=(
    20         os.path.join(os.path.dirname(__file__), 'templates'),
     20        os.path.join(os.path.dirname(__file__), str('templates')),
    2121    ),
    2222    SITE_ID=1,
    2323)
    class FlatpageViewTests(TestCase):  
    8484        # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware'
    8585    ),
    8686    TEMPLATE_DIRS=(
    87         os.path.join(os.path.dirname(__file__), 'templates'),
     87        os.path.join(os.path.dirname(__file__), str('templates')),
    8888    ),
    8989    SITE_ID=1,
    9090)
  • django/contrib/formtools/tests/__init__.py

    diff --git a/django/contrib/formtools/tests/__init__.py b/django/contrib/formtools/tests/__init__.py
    index a21ffde..9a989fc 100644
    a b class TestFormPreview(preview.FormPreview):  
    3636
    3737@override_settings(
    3838    TEMPLATE_DIRS=(
    39         os.path.join(os.path.dirname(__file__), 'templates'),
     39        os.path.join(os.path.dirname(__file__), str('templates')),
    4040    ),
    4141)
    4242class PreviewTests(TestCase):
    class DummyRequest(http.HttpRequest):  
    214214@override_settings(
    215215    SECRET_KEY="123",
    216216    TEMPLATE_DIRS=(
    217         os.path.join(os.path.dirname(__file__), 'templates'),
     217        os.path.join(os.path.dirname(__file__), str('templates')),
    218218    ),
    219219)
    220220class WizardTests(TestCase):
  • django/contrib/formtools/tests/wizard/wizardtests/tests.py

    diff --git a/django/contrib/formtools/tests/wizard/wizardtests/tests.py b/django/contrib/formtools/tests/wizard/wizardtests/tests.py
    index 6403a55..a0ba123 100644
    a b class WizardTests(object):  
    7474
    7575        # ticket #19025: `form` should be included in context
    7676        form = response.context_data['wizard']['form']
    77         self.assertEqual(response.context_data['form'], form)           
     77        self.assertEqual(response.context_data['form'], form)
    7878
    7979    def test_form_finish(self):
    8080        response = self.client.get(self.wizard_url)
    class WizardTestKwargs(TestCase):  
    291291        self.wizard_step_data[0]['form1-user'] = self.testuser.pk
    292292
    293293    def test_template(self):
    294         templates = os.path.join(os.path.dirname(__file__), 'templates')
     294        templates = os.path.join(os.path.dirname(__file__), str('templates'))
    295295        with self.settings(
    296296                TEMPLATE_DIRS=list(settings.TEMPLATE_DIRS) + [templates]):
    297297            response = self.client.get(self.wizard_url)
  • django/contrib/gis/tests/geo3d/tests.py

    diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
    index f7590fe..e8193a3 100644
    a b from .models import (City3D, Interstate2D, Interstate3D, InterstateProj2D,  
    1212    InterstateProj3D, Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D)
    1313
    1414
    15 data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
    16 city_file = os.path.join(data_path, 'cities', 'cities.shp')
    17 vrt_file = os.path.join(data_path, 'test_vrt', 'test_vrt.vrt')
     15data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), str('..'), str('data')))
     16city_file = os.path.join(data_path, str('cities'), str('cities.shp'))
     17vrt_file = os.path.join(data_path, str('test_vrt'), str('test_vrt.vrt'))
    1818
    1919# The coordinates of each city, with Z values corresponding to their
    2020# altitude in meters.
  • django/contrib/gis/tests/geogapp/tests.py

    diff --git a/django/contrib/gis/tests/geogapp/tests.py b/django/contrib/gis/tests/geogapp/tests.py
    index 2fd3560..efcd51a 100644
    a b class GeographyTest(TestCase):  
    6161        from django.contrib.gis.utils import LayerMapping
    6262
    6363        # Getting the shapefile and mapping dictionary.
    64         shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
    65         co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
     64        shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), str('..'), str('data')))
     65        co_shp = os.path.join(shp_path, str('counties'), str('counties.shp'))
    6666        co_mapping = {'name' : 'Name',
    6767                      'state' : 'State',
    6868                      'mpoly' : 'MULTIPOLYGON',
  • django/contrib/gis/tests/layermap/tests.py

    diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
    index a976954..6fd0e46 100644
    a b from .models import (  
    1919    city_mapping, co_mapping, cofeat_mapping, inter_mapping)
    2020
    2121
    22 shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
    23 city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
    24 co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
    25 inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')
    26 invalid_shp = os.path.join(shp_path, 'invalid', 'emptypoints.shp')
     22shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, str('data')))
     23city_shp = os.path.join(shp_path, str('cities'), str('cities.shp'))
     24co_shp = os.path.join(shp_path, str('counties'), str('counties.shp'))
     25inter_shp = os.path.join(shp_path, str('interstates'), str('interstates.shp'))
     26invalid_shp = os.path.join(shp_path, str('invalid'), str('emptypoints.shp'))
    2727
    2828# Dictionaries to hold what's expected in the county shapefile.
    2929NAMES  = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo']
  • django/contrib/sitemaps/tests/http.py

    diff --git a/django/contrib/sitemaps/tests/http.py b/django/contrib/sitemaps/tests/http.py
    index 99042fe..75c869f 100644
    a b class HTTPSitemapTests(SitemapTestsBase):  
    2929        self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
    3030
    3131    @override_settings(
    32         TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),)
     32        TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), str('templates')),)
    3333    )
    3434    def test_simple_sitemap_custom_index(self):
    3535        "A simple sitemap index can be rendered with a custom template"
    class HTTPSitemapTests(SitemapTestsBase):  
    6464        self.assertXMLEqual(response.content.decode('utf-8'), expected_content)
    6565
    6666    @override_settings(
    67         TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),)
     67        TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), str('templates')),)
    6868    )
    6969    def test_simple_custom_sitemap(self):
    7070        "A simple sitemap can be rendered with a custom template"
  • django/contrib/staticfiles/storage.py

    diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
    index 9691b78..507ad1f 100644
    a b class CachedFilesMixin(object):  
    106106        path, filename = os.path.split(clean_name)
    107107        root, ext = os.path.splitext(filename)
    108108        if file_hash is not None:
    109             file_hash = ".%s" % file_hash
    110         hashed_name = os.path.join(path, "%s%s%s" %
     109            file_hash = str(".%s") % file_hash
     110        hashed_name = os.path.join(path, str("%s%s%s") %
    111111                                   (root, file_hash, ext))
    112112        unparsed_name = list(parsed_name)
    113113        unparsed_name[2] = hashed_name
    class AppStaticStorage(FileSystemStorage):  
    288288    for the ``static`` directory of it.
    289289    """
    290290    prefix = None
    291     source_dir = 'static'
     291    source_dir = str('static')
    292292
    293293    def __init__(self, app, *args, **kwargs):
    294294        """
  • django/core/management/commands/compilemessages.py

    diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py
    index b7392b9..32de139 100644
    a b def has_bom(fn):  
    1414            sample.startswith(codecs.BOM_UTF16_BE)
    1515
    1616def compile_messages(stderr, locale=None):
    17     basedirs = [os.path.join('conf', 'locale'), 'locale']
     17    basedirs = [os.path.join(str('conf'), str('locale')), str('locale')]
    1818    if os.environ.get('DJANGO_SETTINGS_MODULE'):
    1919        from django.conf import settings
    2020        basedirs.extend(settings.LOCALE_PATHS)
    def compile_messages(stderr, locale=None):  
    2727
    2828    for basedir in basedirs:
    2929        if locale:
    30             basedir = os.path.join(basedir, locale, 'LC_MESSAGES')
     30            basedir = os.path.join(basedir, locale, str('LC_MESSAGES'))
    3131        for dirpath, dirnames, filenames in os.walk(basedir):
    3232            for f in filenames:
    3333                if f.endswith('.po'):
    34                     stderr.write('processing file %s in %s\n' % (f, dirpath))
     34                    stderr.write(str('processing file %s in %s\n') % (f, dirpath))
    3535                    fn = os.path.join(dirpath, f)
    3636                    if has_bom(fn):
    37                         raise CommandError("The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM." % fn)
     37                        raise CommandError(str("The %s file has a BOM (Byte Order Mark). "
     38                            "Django only supports .po files encoded in UTF-8 and without any BOM.") % fn)
    3839                    pf = os.path.splitext(fn)[0]
    3940                    # Store the names of the .mo and .po files in an environment
    4041                    # variable, rather than doing a string replacement into the
    4142                    # command, so that we can take advantage of shell quoting, to
    4243                    # quote any malicious characters/escaping.
    4344                    # See http://cyberelk.net/tim/articles/cmdline/ar01s02.html
    44                     os.environ['djangocompilemo'] = pf + '.mo'
    45                     os.environ['djangocompilepo'] = pf + '.po'
     45                    os.environ['djangocompilemo'] = pf + str('.mo')
     46                    os.environ['djangocompilepo'] = pf + str('.po')
    4647                    if sys.platform == 'win32': # Different shell-variable syntax
    4748                        cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"'
    4849                    else:
  • django/core/management/commands/loaddata.py

    diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
    index f6f1b10..402485f 100644
    a b from django.core.management.color import no_style  
    1212from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
    1313      IntegrityError, DatabaseError)
    1414from django.db.models import get_apps
    15 from django.utils.encoding import force_text
     15from django.utils._os import path_as_str
     16from django.utils.encoding import force_str, force_text
    1617from itertools import product
    1718
    1819try:
    class Command(BaseCommand):  
    4344        connection = connections[self.using]
    4445
    4546        if not len(fixture_labels):
    46             raise CommandError(
     47            raise CommandError(str(
    4748                "No database fixture specified. Please provide the path of at "
    4849                "least one fixture in the command line."
    49             )
     50            ))
    5051
    5152        self.verbosity = int(options.get('verbosity'))
    5253
    class Command(BaseCommand):  
    8687
    8788        self.compression_types = {
    8889            None:   open,
    89             'gz':   gzip.GzipFile,
    90             'zip':  SingleZipReader
     90            str('gz'):   gzip.GzipFile,
     91            str('zip'):  SingleZipReader
    9192        }
    9293        if has_bz2:
    93             self.compression_types['bz2'] = bz2.BZ2File
     94            self.compression_types[str('bz2')] = bz2.BZ2File
    9495
    9596        app_module_paths = []
    9697        for app in get_apps():
    class Command(BaseCommand):  
    102103                # It's a models.py module
    103104                app_module_paths.append(app.__file__)
    104105
    105         app_fixtures = [os.path.join(os.path.dirname(path), 'fixtures') for path in app_module_paths]
     106        app_fixtures = [os.path.join(os.path.dirname(path), str('fixtures')) for path in app_module_paths]
    106107
    107108        try:
    108109            with connection.constraint_checks_disabled():
    class Command(BaseCommand):  
    132133            sequence_sql = connection.ops.sequence_reset_sql(no_style(), self.models)
    133134            if sequence_sql:
    134135                if self.verbosity >= 2:
    135                     self.stdout.write("Resetting sequences\n")
     136                    self.stdout.write(str("Resetting sequences\n"))
    136137                for line in sequence_sql:
    137138                    cursor.execute(line)
    138139
    class Command(BaseCommand):  
    142143
    143144        if self.verbosity >= 1:
    144145            if self.fixture_object_count == self.loaded_object_count:
    145                 self.stdout.write("Installed %d object(s) from %d fixture(s)" % (
     146                self.stdout.write(str("Installed %d object(s) from %d fixture(s)") % (
    146147                    self.loaded_object_count, self.fixture_count))
    147148            else:
    148                 self.stdout.write("Installed %d object(s) (of %d) from %d fixture(s)" % (
     149                self.stdout.write(str("Installed %d object(s) (of %d) from %d fixture(s)") % (
    149150                    self.loaded_object_count, self.fixture_object_count, self.fixture_count))
    150151
    151152        # Close the DB connection. This is required as a workaround for an
    class Command(BaseCommand):  
    157158
    158159    def load_label(self, fixture_label, app_fixtures):
    159160
    160         parts = fixture_label.split('.')
     161        parts = force_str(fixture_label).split(str('.'))
    161162
    162163        if len(parts) > 1 and parts[-1] in self.compression_types:
    163164            compression_formats = [parts[-1]]
    class Command(BaseCommand):  
    169170            fixture_name = parts[0]
    170171            formats = serializers.get_public_serializer_formats()
    171172        else:
    172             fixture_name, format = '.'.join(parts[:-1]), parts[-1]
     173            fixture_name, format = str('.').join(parts[:-1]), parts[-1]
    173174            if format in serializers.get_public_serializer_formats():
    174175                formats = [format]
    175176            else:
    class Command(BaseCommand):  
    177178
    178179        if formats:
    179180            if self.verbosity >= 2:
    180                 self.stdout.write("Loading '%s' fixtures..." % fixture_name)
     181                self.stdout.write(str("Loading '%s' fixtures...") % fixture_name)
    181182        else:
    182             raise CommandError(
    183                 "Problem installing fixture '%s': %s is not a known serialization format." %
     183            raise CommandError(str(
     184                    "Problem installing fixture '%s': %s is not a known serialization format.") %
    184185                    (fixture_name, format))
    185186
    186187        if os.path.isabs(fixture_name):
    class Command(BaseCommand):  
    195196    def process_dir(self, fixture_dir, fixture_name, compression_formats,
    196197                    serialization_formats):
    197198
    198         humanize = lambda dirname: "'%s'" % dirname if dirname else 'absolute path'
     199        humanize = lambda dirname: str("'%s'") % path_as_str(dirname) if dirname else str('absolute path')
    199200
    200201        if self.verbosity >= 2:
    201             self.stdout.write("Checking %s for fixtures..." % humanize(fixture_dir))
     202            self.stdout.write(str("Checking %s for fixtures...") % humanize(fixture_dir))
    202203
    203204        label_found = False
    204205        for combo in product([self.using, None], serialization_formats, compression_formats):
    205206            database, format, compression_format = combo
    206             file_name = '.'.join(
     207            file_name = str('.').join(
    207208                p for p in [
    208209                    fixture_name, database, format, compression_format
    209210                ]
    class Command(BaseCommand):  
    211212            )
    212213
    213214            if self.verbosity >= 3:
    214                 self.stdout.write("Trying %s for %s fixture '%s'..." % \
     215                self.stdout.write(str("Trying %s for %s fixture '%s'...") % \
    215216                    (humanize(fixture_dir), file_name, fixture_name))
    216217            full_path = os.path.join(fixture_dir, file_name)
    217218            open_method = self.compression_types[compression_format]
    class Command(BaseCommand):  
    219220                fixture = open_method(full_path, 'r')
    220221            except IOError:
    221222                if self.verbosity >= 2:
    222                     self.stdout.write("No %s fixture '%s' in %s." % \
     223                    self.stdout.write(str("No %s fixture '%s' in %s.") % \
    223224                        (format, fixture_name, humanize(fixture_dir)))
    224225            else:
    225226                try:
    226227                    if label_found:
    227                         raise CommandError("Multiple fixtures named '%s' in %s. Aborting." %
     228                        raise CommandError(str("Multiple fixtures named '%s' in %s. Aborting.") %
    228229                            (fixture_name, humanize(fixture_dir)))
    229230
    230231                    self.fixture_count += 1
    231232                    objects_in_fixture = 0
    232233                    loaded_objects_in_fixture = 0
    233234                    if self.verbosity >= 2:
    234                         self.stdout.write("Installing %s fixture '%s' from %s." % \
     235                        self.stdout.write(str("Installing %s fixture '%s' from %s.") % \
    235236                            (format, fixture_name, humanize(fixture_dir)))
    236237
    237238                    objects = serializers.deserialize(format, fixture, using=self.using, ignorenonexistent=self.ignore)
    class Command(BaseCommand):  
    257258                    label_found = True
    258259                except Exception as e:
    259260                    if not isinstance(e, CommandError):
    260                         e.args = ("Problem installing fixture '%s': %s" % (full_path, e),)
     261                        e.args = (str("Problem installing fixture '%s': %s") % (path_as_str(full_path), e),)
    261262                    raise
    262263                finally:
    263264                    fixture.close()
    class Command(BaseCommand):  
    265266                # If the fixture we loaded contains 0 objects, assume that an
    266267                # error was encountered during fixture loading.
    267268                if objects_in_fixture == 0:
    268                     raise CommandError(
    269                         "No fixture data found for '%s'. (File format may be invalid.)" %
     269                    raise CommandError(str(
     270                        "No fixture data found for '%s'. (File format may be invalid.)") %
    270271                            (fixture_name))
  • django/core/management/sql.py

    diff --git a/django/core/management/sql.py b/django/core/management/sql.py
    index 78cd17a..e887194 100644
    a b def _split_statements(content):  
    159159
    160160def custom_sql_for_model(model, style, connection):
    161161    opts = model._meta
    162     app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql'))
     162    app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), str('sql')))
    163163    output = []
    164164
    165165    # Post-creation SQL should come before any initial SQL data is loaded.
    def custom_sql_for_model(model, style, connection):  
    171171            output.extend(f.post_create_sql(style, model._meta.db_table))
    172172
    173173    # Find custom SQL, if it's available.
    174     backend_name = connection.settings_dict['ENGINE'].split('.')[-1]
    175     sql_files = [os.path.join(app_dir, "%s.%s.sql" % (opts.object_name.lower(), backend_name)),
    176                  os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
     174    backend_name = str(connection.settings_dict['ENGINE'].split('.')[-1])
     175    sql_files = [os.path.join(app_dir, str('%s.%s.sql') % (opts.object_name.lower(), backend_name)),
     176                 os.path.join(app_dir, str('%s.sql') % opts.object_name.lower())]
    177177    for sql_file in sql_files:
    178178        if os.path.exists(sql_file):
    179179            with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp:
  • django/db/utils.py

    diff --git a/django/db/utils.py b/django/db/utils.py
    index a912986..7d6b60d 100644
    a b def load_backend(backend_name):  
    2727    except ImportError as e_user:
    2828        # The database backend wasn't found. Display a helpful error message
    2929        # listing all possible (built-in) database backends.
    30         backend_dir = os.path.join(os.path.dirname(__file__), 'backends')
     30        backend_dir = os.path.join(os.path.dirname(__file__), str('backends'))
    3131        try:
    3232            builtin_backends = [
    3333                name for _, name, ispkg in pkgutil.iter_modules([backend_dir])
  • django/utils/translation/trans_real.py

    diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
    index 1bcef2d..aa7815f 100644
    a b def translation(language):  
    103103    """
    104104    global _translations
    105105
     106    language = str(language)
     107
    106108    t = _translations.get(language, None)
    107109    if t is not None:
    108110        return t
    109111
    110112    from django.conf import settings
    111113
    112     globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
     114    globalpath = os.path.join(os.path.dirname(sys.modules[settings.__module__].__file__), str('locale'))
    113115
    114116    def _fetch(lang, fallback=None):
    115117
    def translation(language):  
    123125
    124126        def _translation(path):
    125127            try:
    126                 t = gettext_module.translation('django', path, [loc], DjangoTranslation)
     128                t = gettext_module.translation(str('django'), path, [loc], DjangoTranslation)
    127129                t.set_language(lang)
    128130                return t
    129131            except IOError:
    def translation(language):  
    151153
    152154        for appname in reversed(settings.INSTALLED_APPS):
    153155            app = import_module(appname)
    154             apppath = os.path.join(os.path.dirname(app.__file__), 'locale')
     156            apppath = os.path.join(os.path.dirname(app.__file__), str('locale'))
    155157
    156158            if os.path.isdir(apppath):
    157159                res = _merge(apppath)
    def all_locale_paths():  
    337339    """
    338340    from django.conf import settings
    339341    globalpath = os.path.join(
    340         os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
     342        os.path.dirname(sys.modules[settings.__module__].__file__), str('locale'))
    341343    return [globalpath] + list(settings.LOCALE_PATHS)
    342344
    343345def check_for_language(lang_code):
    def check_for_language(lang_code):  
    348350    or session and during format localization.
    349351    """
    350352    for path in all_locale_paths():
    351         if gettext_module.find('django', path, [to_locale(lang_code)]) is not None:
     353        if gettext_module.find(str('django'), path, [str(to_locale(lang_code))]) is not None:
    352354            return True
    353355    return False
    354356
    def get_language_from_request(request, check_path=False):  
    426428            if lang.lower() not in supported:
    427429                continue
    428430            for path in all_locale_paths():
    429                 if os.path.exists(os.path.join(path, dirname, 'LC_MESSAGES', 'django.mo')):
     431                if os.path.exists(os.path.join(path, str(dirname), str('LC_MESSAGES'), str('django.mo'))):
    430432                    _accepted[normalized] = lang
    431433                    return lang
    432434
  • django/views/static.py

    diff --git a/django/views/static.py b/django/views/static.py
    index f61ba28..324250f 100644
    a b  
     1
    12"""
    23Views and functions for serving static files. These are only to be used
    34during development, and SHOULD NOT be used in a production setting.
    except ImportError: # Python 2  
    1718from django.http import (CompatibleStreamingHttpResponse, Http404,
    1819    HttpResponse, HttpResponseRedirect, HttpResponseNotModified)
    1920from django.template import loader, Template, Context, TemplateDoesNotExist
     21from django.utils._os import path_as_str
    2022from django.utils.http import http_date, parse_http_date
    2123from django.utils.translation import ugettext as _, ugettext_noop
    2224
    def serve(request, path, document_root=None, show_indexes=False):  
    4951        newpath = os.path.join(newpath, part).replace('\\', '/')
    5052    if newpath and path != newpath:
    5153        return HttpResponseRedirect(newpath)
    52     fullpath = os.path.join(document_root, newpath)
     54    fullpath = os.path.join(path_as_str(document_root), path_as_str(newpath))
    5355    if os.path.isdir(fullpath):
    5456        if show_indexes:
    5557            return directory_index(newpath, fullpath)
  • tests/modeltests/model_forms/tests.py

    diff --git a/tests/modeltests/model_forms/tests.py b/tests/modeltests/model_forms/tests.py
    index c47de45..3a7a24d 100644
    a b class OldFormForXTests(TestCase):  
    12821282        # it comes to validation. This specifically tests that #6302 is fixed for
    12831283        # both file fields and image fields.
    12841284
    1285         with open(os.path.join(os.path.dirname(__file__), "test.png"), 'rb') as fp:
     1285        with open(os.path.join(os.path.dirname(__file__), str('test.png')), 'rb') as fp:
    12861286            image_data = fp.read()
    1287         with open(os.path.join(os.path.dirname(__file__), "test2.png"), 'rb') as fp:
     1287        with open(os.path.join(os.path.dirname(__file__), str('test2.png')), 'rb') as fp:
    12881288            image_data2 = fp.read()
    12891289
    12901290        f = ImageFileForm(
  • tests/regressiontests/admin_scripts/tests.py

    diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
    index a26d7a6..27cd998 100644
    a b class AdminScriptTestCase(unittest.TestCase):  
    2727    def write_settings(self, filename, apps=None, is_dir=False, sdict=None):
    2828        test_dir = os.path.dirname(os.path.dirname(__file__))
    2929        if is_dir:
    30             settings_dir = os.path.join(test_dir, filename)
     30            settings_dir = os.path.join(test_dir, str(filename))
    3131            os.mkdir(settings_dir)
    32             settings_file_path = os.path.join(settings_dir, '__init__.py')
     32            settings_file_path = os.path.join(settings_dir, str('__init__.py'))
    3333        else:
    34             settings_file_path = os.path.join(test_dir, filename)
     34            settings_file_path = os.path.join(test_dir, str(filename))
    3535
    3636        with open(settings_file_path, 'w') as settings_file:
    3737            settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
    class AdminScriptTestCase(unittest.TestCase):  
    5757                    settings_file.write("%s = %s\n" % (k, v))
    5858
    5959    def remove_settings(self, filename, is_dir=False):
    60         full_name = os.path.join(test_dir, filename)
     60        full_name = os.path.join(test_dir, str(filename))
    6161        if is_dir:
    6262            shutil.rmtree(full_name)
    6363        else:
    class AdminScriptTestCase(unittest.TestCase):  
    6868        try:
    6969            if sys.platform.startswith('java'):
    7070                # Jython produces module$py.class files
    71                 os.remove(re.sub(r'\.py$', '$py.class', full_name))
     71                os.remove(re.sub(str(r'\.py$'), str('$py.class'), full_name))
    7272            else:
    7373                # CPython produces module.pyc files
    74                 os.remove(full_name + 'c')
     74                os.remove(full_name + str('c'))
    7575        except OSError:
    7676            pass
    7777        # Also remove a __pycache__ directory, if it exists
    78         cache_name = os.path.join(test_dir, '__pycache__')
     78        cache_name = os.path.join(test_dir, str('__pycache__'))
    7979        if os.path.isdir(cache_name):
    8080            shutil.rmtree(cache_name)
    8181
    class AdminScriptTestCase(unittest.TestCase):  
    135135
    136136    def run_django_admin(self, args, settings_file=None):
    137137        bin_dir = os.path.abspath(os.path.dirname(bin.__file__))
    138         return self.run_test(os.path.join(bin_dir, 'django-admin.py'), args, settings_file)
     138        return self.run_test(os.path.join(bin_dir, str('django-admin.py')), args, settings_file)
    139139
    140140    def run_manage(self, args, settings_file=None):
    141141        def safe_remove(path):
    class AdminScriptTestCase(unittest.TestCase):  
    145145                pass
    146146
    147147        conf_dir = os.path.dirname(conf.__file__)
    148         template_manage_py = os.path.join(conf_dir, 'project_template', 'manage.py')
     148        template_manage_py = os.path.join(conf_dir, str('project_template'), str('manage.py'))
    149149
    150         test_manage_py = os.path.join(test_dir, 'manage.py')
     150        test_manage_py = os.path.join(test_dir, str('manage.py'))
    151151        shutil.copyfile(template_manage_py, test_manage_py)
    152152
    153153        with open(test_manage_py, 'r') as fp:
    class AdminScriptTestCase(unittest.TestCase):  
    162162
    163163    def assertNoOutput(self, stream):
    164164        "Utility assertion: assert that the given stream is empty"
    165         self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
     165        self.assertEqual(len(stream), 0, str("Stream should be empty: actually contains '%s'") % stream)
    166166
    167167    def assertOutput(self, stream, msg):
    168168        "Utility assertion: assert that the given message exists in the output"
    169         self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))
     169        msg = str(msg)
     170        self.assertTrue(msg in stream, str("'%s' does not match actual output text '%s'") % (msg, stream))
    170171
    171172    def assertNotInOutput(self, stream, msg):
    172173        "Utility assertion: assert that the given message doesn't exist in the output"
    173         self.assertFalse(msg in stream, "'%s' matches actual output text '%s'" % (msg, stream))
     174        msg = str(msg)
     175        self.assertFalse(msg in stream, str("'%s' matches actual output text '%s'") % (msg, stream))
    174176
    175177##########################################################################
    176178# DJANGO ADMIN TESTS
    class DjangoAdminSettingsDirectory(AdminScriptTestCase):  
    554556    def test_setup_environ(self):
    555557        "directory: startapp creates the correct directory"
    556558        args = ['startapp', 'settings_test']
    557         app_path = os.path.join(test_dir, 'settings_test')
     559        app_path = os.path.join(test_dir, str('settings_test'))
    558560        out, err = self.run_django_admin(args, 'regressiontests.settings')
    559561        self.addCleanup(shutil.rmtree, app_path)
    560562        self.assertNoOutput(err)
    class DjangoAdminSettingsDirectory(AdminScriptTestCase):  
    562564
    563565    def test_setup_environ_custom_template(self):
    564566        "directory: startapp creates the correct directory with a custom template"
    565         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'app_template')
     567        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('app_template'))
    566568        args = ['startapp', '--template', template_path, 'custom_settings_test']
    567         app_path = os.path.join(test_dir, 'custom_settings_test')
     569        app_path = os.path.join(test_dir, str('custom_settings_test'))
    568570        out, err = self.run_django_admin(args, 'regressiontests.settings')
    569571        self.addCleanup(shutil.rmtree, app_path)
    570572        self.assertNoOutput(err)
    571573        self.assertTrue(os.path.exists(app_path))
    572         self.assertTrue(os.path.exists(os.path.join(app_path, 'api.py')))
     574        self.assertTrue(os.path.exists(os.path.join(app_path, str('api.py'))))
    573575
    574576    def test_builtin_command(self):
    575577        "directory: django-admin builtin commands fail with an error when no settings provided"
    class ManageSettingsWithImportError(AdminScriptTestCase):  
    994996
    995997    def write_settings_with_import_error(self, filename, apps=None, is_dir=False, sdict=None):
    996998        if is_dir:
    997             settings_dir = os.path.join(test_dir, filename)
     999            settings_dir = os.path.join(test_dir, str(filename))
    9981000            os.mkdir(settings_dir)
    999             settings_file_path = os.path.join(settings_dir, '__init__.py')
     1001            settings_file_path = os.path.join(settings_dir, str('__init__.py'))
    10001002        else:
    1001             settings_file_path = os.path.join(test_dir, filename)
     1003            settings_file_path = os.path.join(test_dir, str(filename))
    10021004        with open(settings_file_path, 'w') as settings_file:
    10031005            settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
    10041006            settings_file.write('# The next line will cause an import error:\nimport foo42bar\n')
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14111413    def test_simple_project(self):
    14121414        "Make sure the startproject management command creates a project"
    14131415        args = ['startproject', 'testproject']
    1414         testproject_dir = os.path.join(test_dir, 'testproject')
     1416        testproject_dir = os.path.join(test_dir, str('testproject'))
    14151417        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14161418
    14171419        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14261428    def test_invalid_project_name(self):
    14271429        "Make sure the startproject management command validates a project name"
    14281430        args = ['startproject', '7testproject']
    1429         testproject_dir = os.path.join(test_dir, '7testproject')
     1431        testproject_dir = os.path.join(test_dir, str('7testproject'))
    14301432        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14311433
    14321434        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14361438    def test_simple_project_different_directory(self):
    14371439        "Make sure the startproject management command creates a project in a specific directory"
    14381440        args = ['startproject', 'testproject', 'othertestproject']
    1439         testproject_dir = os.path.join(test_dir, 'othertestproject')
     1441        testproject_dir = os.path.join(test_dir, str('othertestproject'))
    14401442        os.mkdir(testproject_dir)
    14411443        self.addCleanup(shutil.rmtree, testproject_dir)
    14421444
    14431445        out, err = self.run_django_admin(args)
    14441446        self.assertNoOutput(err)
    1445         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'manage.py')))
     1447        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('manage.py'))))
    14461448
    14471449        # running again..
    14481450        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14511453
    14521454    def test_custom_project_template(self):
    14531455        "Make sure the startproject management command is able to use a different project template"
    1454         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1456        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    14551457        args = ['startproject', '--template', template_path, 'customtestproject']
    1456         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1458        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    14571459        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14581460
    14591461        out, err = self.run_django_admin(args)
    14601462        self.assertNoOutput(err)
    14611463        self.assertTrue(os.path.isdir(testproject_dir))
    1462         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
     1464        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
    14631465
    14641466    def test_template_dir_with_trailing_slash(self):
    14651467        "Ticket 17475: Template dir passed has a trailing path separator"
    1466         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template' + os.sep)
     1468        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template') + os.sep)
    14671469        args = ['startproject', '--template', template_path, 'customtestproject']
    1468         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1470        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    14691471        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14701472
    14711473        out, err = self.run_django_admin(args)
    14721474        self.assertNoOutput(err)
    14731475        self.assertTrue(os.path.isdir(testproject_dir))
    1474         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
     1476        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
    14751477
    14761478    def test_custom_project_template_from_tarball_by_path(self):
    14771479        "Make sure the startproject management command is able to use a different project template from a tarball"
    1478         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template.tgz')
     1480        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template.tgz'))
    14791481        args = ['startproject', '--template', template_path, 'tarballtestproject']
    1480         testproject_dir = os.path.join(test_dir, 'tarballtestproject')
     1482        testproject_dir = os.path.join(test_dir, str('tarballtestproject'))
    14811483        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14821484
    14831485        out, err = self.run_django_admin(args)
    14841486        self.assertNoOutput(err)
    14851487        self.assertTrue(os.path.isdir(testproject_dir))
    1486         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1488        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    14871489
    14881490    def test_custom_project_template_from_tarball_to_alternative_location(self):
    14891491        "Startproject can use a project template from a tarball and create it in a specified location"
    1490         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template.tgz')
     1492        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template.tgz'))
    14911493        args = ['startproject', '--template', template_path, 'tarballtestproject', 'altlocation']
    1492         testproject_dir = os.path.join(test_dir, 'altlocation')
     1494        testproject_dir = os.path.join(test_dir, str('altlocation'))
    14931495        os.mkdir(testproject_dir)
    14941496        self.addCleanup(shutil.rmtree, testproject_dir)
    14951497
    14961498        out, err = self.run_django_admin(args)
    14971499        self.assertNoOutput(err)
    14981500        self.assertTrue(os.path.isdir(testproject_dir))
    1499         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1501        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15001502
    15011503    def test_custom_project_template_from_tarball_by_url(self):
    15021504        "Make sure the startproject management command is able to use a different project template from a tarball via a url"
    15031505        template_url = '%s/admin_scripts/custom_templates/project_template.tgz' % self.live_server_url
    15041506
    15051507        args = ['startproject', '--template', template_url, 'urltestproject']
    1506         testproject_dir = os.path.join(test_dir, 'urltestproject')
     1508        testproject_dir = os.path.join(test_dir, str('urltestproject'))
    15071509        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15081510
    15091511        out, err = self.run_django_admin(args)
    15101512        self.assertNoOutput(err)
    15111513        self.assertTrue(os.path.isdir(testproject_dir))
    1512         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1514        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15131515
    15141516    def test_project_template_tarball_url(self):
    15151517        "Startproject management command handles project template tar/zip balls from non-canonical urls"
    15161518        template_url = '%s/admin_scripts/custom_templates/project_template.tgz/' % self.live_server_url
    15171519
    15181520        args = ['startproject', '--template', template_url, 'urltestproject']
    1519         testproject_dir = os.path.join(test_dir, 'urltestproject')
     1521        testproject_dir = os.path.join(test_dir, str('urltestproject'))
    15201522        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15211523
    15221524        out, err = self.run_django_admin(args)
    15231525        self.assertNoOutput(err)
    15241526        self.assertTrue(os.path.isdir(testproject_dir))
    1525         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1527        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15261528
    15271529    def test_file_without_extension(self):
    15281530        "Make sure the startproject management command is able to render custom files"
    1529         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1531        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15301532        args = ['startproject', '--template', template_path, 'customtestproject', '-e', 'txt', '-n', 'Procfile']
    1531         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1533        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    15321534        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15331535
    15341536        out, err = self.run_django_admin(args)
    15351537        self.assertNoOutput(err)
    15361538        self.assertTrue(os.path.isdir(testproject_dir))
    1537         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
    1538         base_path = os.path.join(testproject_dir, 'additional_dir')
    1539         for f in ('Procfile', 'additional_file.py', 'requirements.txt'):
     1539        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
     1540        base_path = os.path.join(testproject_dir, str('additional_dir'))
     1541        for f in (str('Procfile'), str('additional_file.py'), str('requirements.txt')):
    15401542            self.assertTrue(os.path.exists(os.path.join(base_path, f)))
    15411543            with open(os.path.join(base_path, f)) as fh:
    15421544                self.assertEqual(fh.read(),
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15441546
    15451547    def test_custom_project_template_context_variables(self):
    15461548        "Make sure template context variables are rendered with proper values"
    1547         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1549        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15481550        args = ['startproject', '--template', template_path, 'another_project', 'project_dir']
    1549         testproject_dir = os.path.join(test_dir, 'project_dir')
     1551        testproject_dir = os.path.join(test_dir, str('project_dir'))
    15501552        os.mkdir(testproject_dir)
    15511553        self.addCleanup(shutil.rmtree, testproject_dir)
    15521554        out, err = self.run_django_admin(args)
    15531555        self.assertNoOutput(err)
    1554         test_manage_py = os.path.join(testproject_dir, 'manage.py')
     1556        test_manage_py = os.path.join(testproject_dir, str('manage.py'))
    15551557        with open(test_manage_py, 'r') as fp:
    15561558            content = fp.read()
    1557             self.assertIn("project_name = 'another_project'", content)
    1558             self.assertIn("project_directory = '%s'" % testproject_dir, content)
     1559            self.assertIn(str("project_name = 'another_project'"), content)
     1560            self.assertIn(str("project_directory = '%s'") % testproject_dir, content)
    15591561
    15601562    def test_no_escaping_of_project_variables(self):
    15611563        "Make sure template context variables are not html escaped"
    15621564        # We're using a custom command so we need the alternate settings
    15631565        self.write_settings('alternate_settings.py')
    15641566        self.addCleanup(self.remove_settings, 'alternate_settings.py')
    1565         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1567        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15661568        args = ['custom_startproject', '--template', template_path, 'another_project', 'project_dir', '--extra', '<&>', '--settings=alternate_settings']
    1567         testproject_dir = os.path.join(test_dir, 'project_dir')
     1569        testproject_dir = os.path.join(test_dir, str('project_dir'))
    15681570        os.mkdir(testproject_dir)
    15691571        self.addCleanup(shutil.rmtree, testproject_dir)
    15701572        out, err = self.run_manage(args)
    15711573        self.assertNoOutput(err)
    1572         test_manage_py = os.path.join(testproject_dir, 'additional_dir', 'extra.py')
     1574        test_manage_py = os.path.join(testproject_dir, str('additional_dir'), str('extra.py'))
    15731575        with open(test_manage_py, 'r') as fp:
    15741576            content = fp.read()
    15751577            self.assertIn("<&>", content)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15791581        Make sure an exception is raised when the provided
    15801582        destination directory doesn't exist
    15811583        """
    1582         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1584        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15831585        args = ['startproject', '--template', template_path, 'yet_another_project', 'project_dir2']
    1584         testproject_dir = os.path.join(test_dir, 'project_dir2')
     1586        testproject_dir = os.path.join(test_dir, str('project_dir2'))
    15851587        out, err = self.run_django_admin(args)
    15861588        self.assertNoOutput(out)
    1587         self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir)
     1589        self.assertOutput(err, str("Destination directory '%s' does not exist, please create it first.") % testproject_dir)
    15881590        self.assertFalse(os.path.exists(testproject_dir))
    15891591
    15901592    def test_custom_project_template_with_non_ascii_templates(self):
    15911593        "Ticket 18091: Make sure the startproject management command is able to render templates with non-ASCII content"
    1592         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1594        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15931595        args = ['startproject', '--template', template_path, '--extension=txt', 'customtestproject']
    1594         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1596        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    15951597        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15961598
    15971599        out, err = self.run_django_admin(args)
    15981600        self.assertNoOutput(err)
    15991601        self.assertTrue(os.path.isdir(testproject_dir))
    1600         path = os.path.join(testproject_dir, 'ticket-18091-non-ascii-template.txt')
     1602        path = os.path.join(testproject_dir, str('ticket-18091-non-ascii-template.txt'))
    16011603        with codecs.open(path, 'r', 'utf-8') as f:
    16021604            self.assertEqual(f.read(),
    16031605                'Some non-ASCII text for testing ticket #18091:\nüäö €\n')
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 62f69f6..96962b2 100644
    a b class AdminViewFormUrlTest(TestCase):  
    633633        Refs #17515.
    634634        """
    635635        template_dirs = settings.TEMPLATE_DIRS + (
    636             os.path.join(os.path.dirname(__file__), 'templates'),)
     636            os.path.join(os.path.dirname(__file__), str('templates')),)
    637637        with self.settings(TEMPLATE_DIRS=template_dirs):
    638638            response = self.client.get("/test_admin/admin/admin_views/color2/")
    639639            self.assertTrue('custom_filter_template.html' in [t.name for t in response.templates])
  • tests/regressiontests/app_loading/tests.py

    diff --git a/tests/regressiontests/app_loading/tests.py b/tests/regressiontests/app_loading/tests.py
    index 0e66a5a..10c6aef 100644
    a b class EggLoadingTest(TestCase):  
    1313
    1414    def setUp(self):
    1515        self.old_path = sys.path[:]
    16         self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
     16        self.egg_dir = str('%s/eggs') % os.path.dirname(__file__)
    1717
    1818        # This test adds dummy applications to the app cache. These
    1919        # need to be removed in order to prevent bad interactions
  • tests/regressiontests/file_storage/tests.py

    diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
    index 595b65d..c569e54 100644
    a b class DimensionClosingBug(unittest.TestCase):  
    534534        from django.core.files import images
    535535        images.open = catching_open
    536536        try:
    537             get_image_dimensions(os.path.join(os.path.dirname(__file__), "test1.png"))
     537            get_image_dimensions(os.path.join(os.path.dirname(__file__), str('test1.png')))
    538538        finally:
    539539            del images.open
    540540        self.assertTrue(FileWrapper._closed)
    class InconsistentGetImageDimensionsBug(unittest.TestCase):  
    551551        """
    552552        from django.core.files.images import ImageFile
    553553
    554         img_path = os.path.join(os.path.dirname(__file__), "test.png")
     554        img_path = os.path.join(os.path.dirname(__file__), str('test.png'))
    555555        image = ImageFile(open(img_path, 'rb'))
    556556        image_pil = Image.open(img_path)
    557557        size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image)
  • tests/regressiontests/fixtures_regress/tests.py

    diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
    index 55363bc..2647e7f 100644
    a b class TestFixtures(TestCase):  
    127127        """
    128128        load_absolute_path = os.path.join(
    129129            os.path.dirname(__file__),
    130             'fixtures',
    131             'absolute.json'
     130            str('fixtures'),
     131            str('absolute.json')
    132132        )
    133133        management.call_command(
    134134            'loaddata',
    class TestFixtures(TestCase):  
    390390
    391391    _cur_dir = os.path.dirname(os.path.abspath(__file__))
    392392
    393     @override_settings(FIXTURE_DIRS=[os.path.join(_cur_dir, 'fixtures_1'),
    394                                      os.path.join(_cur_dir, 'fixtures_2')])
     393    @override_settings(FIXTURE_DIRS=[os.path.join(_cur_dir, str('fixtures_1')),
     394                                     os.path.join(_cur_dir, str('fixtures_2'))])
    395395    def test_loaddata_forward_refs_split_fixtures(self):
    396396        """
    397397        Regression for #17530 - should be able to cope with forward references
    class TestFixtures(TestCase):  
    429429            commit=False,
    430430            stdout=stdout_output,
    431431        )
    432         self.assertTrue("No xml fixture 'this_fixture_doesnt_exist' in" in
     432        self.assertIn(str("No xml fixture 'this_fixture_doesnt_exist' in"),
    433433            stdout_output.getvalue())
    434434
    435435
  • tests/regressiontests/forms/tests/fields.py

    diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
    index 1027afc..2e18db3 100644
    a b class FieldsTests(SimpleTestCase):  
    992992            self.assertTrue(got[0].endswith(exp[0]))
    993993
    994994    def test_filepathfield_folders(self):
    995         path = os.path.dirname(__file__) + '/filepath_test_files/'
     995        path = os.path.dirname(__file__) + str('/filepath_test_files/')
    996996        f = FilePathField(path=path, allow_folders=True, allow_files=False)
    997997        f.choices.sort()
    998998        expected = [
  • tests/regressiontests/httpwrappers/tests.py

    diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
    index 2d172ad..9b3d48d 100644
    a b class StreamingHttpResponseTests(TestCase):  
    483483
    484484class FileCloseTests(TestCase):
    485485    def test_response(self):
    486         filename = os.path.join(os.path.dirname(__file__), 'abc.txt')
     486        filename = os.path.join(os.path.dirname(__file__), str('abc.txt'))
    487487
    488488        # file isn't closed until we close the response.
    489489        file1 = open(filename)
    class FileCloseTests(TestCase):  
    516516        self.assertTrue(file2.closed)
    517517
    518518    def test_streaming_response(self):
    519         filename = os.path.join(os.path.dirname(__file__), 'abc.txt')
     519        filename = os.path.join(os.path.dirname(__file__), str('abc.txt'))
    520520
    521521        # file isn't closed until we close the response.
    522522        file1 = open(filename)
  • tests/regressiontests/i18n/contenttypes/tests.py

    diff --git a/tests/regressiontests/i18n/contenttypes/tests.py b/tests/regressiontests/i18n/contenttypes/tests.py
    index 178232f..c6cfe0b 100644
    a b from django.utils import translation  
    1313@override_settings(
    1414    USE_I18N=True,
    1515    LOCALE_PATHS=(
    16         os.path.join(os.path.dirname(__file__), 'locale'),
     16        os.path.join(os.path.dirname(__file__), str('locale')),
    1717    ),
    1818    LANGUAGE_CODE='en',
    1919    LANGUAGES=(
  • tests/regressiontests/i18n/patterns/tests.py

    diff --git a/tests/regressiontests/i18n/patterns/tests.py b/tests/regressiontests/i18n/patterns/tests.py
    index 73c9f56..213ba8f 100644
    a b from django.utils import translation  
    1313@override_settings(
    1414    USE_I18N=True,
    1515    LOCALE_PATHS=(
    16         os.path.join(os.path.dirname(__file__), 'locale'),
     16        os.path.join(os.path.dirname(__file__), str('locale')),
    1717    ),
    1818    TEMPLATE_DIRS=(
    19         os.path.join(os.path.dirname(__file__), 'templates'),
     19        os.path.join(os.path.dirname(__file__), str('templates')),
    2020    ),
    2121    LANGUAGE_CODE='en',
    2222    LANGUAGES=(
  • tests/regressiontests/i18n/tests.py

    diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
    index 2e0c097..60ee8d9 100644
    a b from .patterns.tests import (URLRedirectWithoutTrailingSlashTests,  
    4646
    4747here = os.path.dirname(os.path.abspath(__file__))
    4848extended_locale_paths = settings.LOCALE_PATHS + (
    49     os.path.join(here, 'other', 'locale'),
     49    os.path.join(here, str('other'), str('locale')),
    5050)
    5151
    5252class TranslationTests(TestCase):
    class TranslationTests(TestCase):  
    266266        self.assertEqual(trans_real.to_language('en_US'), 'en-us')
    267267        self.assertEqual(trans_real.to_language('sr_Lat'), 'sr-lat')
    268268
    269     @override_settings(LOCALE_PATHS=(os.path.join(here, 'other', 'locale'),))
     269    @override_settings(LOCALE_PATHS=(os.path.join(here, str('other'), str('locale')),))
    270270    def test_bad_placeholder_1(self):
    271271        """
    272272        Error in translation file should not crash template rendering
    class TranslationTests(TestCase):  
    278278            rendered = t.render(Context({'person': 'James'}))
    279279            self.assertEqual(rendered, 'My name is James.')
    280280
    281     @override_settings(LOCALE_PATHS=(os.path.join(here, 'other', 'locale'),))
     281    @override_settings(LOCALE_PATHS=(os.path.join(here, str('other'), str('locale')),))
    282282    def test_bad_placeholder_2(self):
    283283        """
    284284        Error in translation file should not crash template rendering
    class FormattingTests(TestCase):  
    666666        with self.settings(USE_L10N=True,
    667667                FORMAT_MODULE_PATH='regressiontests.i18n.other.locale'):
    668668            with translation.override('de', deactivate=True):
    669                 old = "%r" % get_format_modules(reverse=True)
    670                 new = "%r" % get_format_modules(reverse=True) # second try
     669                old = str("%r") % get_format_modules(reverse=True)
     670                new = str("%r") % get_format_modules(reverse=True) # second try
    671671                self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.')
    672672
    673673    def test_localize_templatetag_and_filter(self):
  • tests/regressiontests/servers/tests.py

    diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py
    index f54e34c..87b7c81 100644
    a b from .models import Person  
    2222TEST_ROOT = os.path.dirname(__file__)
    2323TEST_SETTINGS = {
    2424    'MEDIA_URL': '/media/',
    25     'MEDIA_ROOT': os.path.join(TEST_ROOT, 'media'),
     25    'MEDIA_ROOT': os.path.join(TEST_ROOT, str('media')),
    2626    'STATIC_URL': '/static/',
    27     'STATIC_ROOT': os.path.join(TEST_ROOT, 'static'),
     27    'STATIC_ROOT': os.path.join(TEST_ROOT, str('static')),
    2828}
    2929
    3030
  • tests/regressiontests/staticfiles_tests/tests.py

    diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py
    index 0c8e7db..c7f25ea 100644
    a b from django.core.exceptions import ImproperlyConfigured  
    1515from django.core.management import call_command
    1616from django.test import TestCase
    1717from django.test.utils import override_settings
    18 from django.utils.encoding import smart_text
     18from django.utils.encoding import smart_text, force_str
    1919from django.utils.functional import empty
    20 from django.utils._os import rmtree_errorhandler
     20from django.utils._os import path_as_text, rmtree_errorhandler
    2121from django.utils import six
    2222
    2323from django.contrib.staticfiles import finders, storage
    TEST_SETTINGS = {  
    2727    'DEBUG': True,
    2828    'MEDIA_URL': '/media/',
    2929    'STATIC_URL': '/static/',
    30     'MEDIA_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'media'),
    31     'STATIC_ROOT': os.path.join(TEST_ROOT, 'project', 'site_media', 'static'),
     30    'MEDIA_ROOT': os.path.join(TEST_ROOT, str('project'), str('site_media'), str('media')),
     31    'STATIC_ROOT': os.path.join(TEST_ROOT, str('project'), str('site_media'), str('static')),
    3232    'STATICFILES_DIRS': (
    33         os.path.join(TEST_ROOT, 'project', 'documents'),
    34         ('prefix', os.path.join(TEST_ROOT, 'project', 'prefixed')),
     33        os.path.join(TEST_ROOT, str('project'), str('documents')),
     34        (str('prefix'), os.path.join(TEST_ROOT, str('project'), str('prefixed'))),
    3535    ),
    3636    'STATICFILES_FINDERS': (
    3737        'django.contrib.staticfiles.finders.FileSystemFinder',
    class BaseStaticFilesTestCase(object):  
    5555        # run and pick up changes in settings.STATICFILES_DIRS.
    5656        finders._finders.clear()
    5757
    58         testfiles_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test')
     58        testfiles_path = os.path.join(TEST_ROOT, str('apps'), str('test'), str('static'), str('test'))
    5959        # To make sure SVN doesn't hangs itself with the non-ASCII characters
    6060        # during checkout, we actually create one file dynamically.
    61         self._nonascii_filepath = os.path.join(testfiles_path, '\u2297.txt')
     61        self._nonascii_filepath = os.path.join(testfiles_path, force_str('\u2297.txt'))
    6262        with codecs.open(self._nonascii_filepath, 'w', 'utf-8') as f:
    6363            f.write("\u2297 in the app dir")
    6464        # And also create the stupid hidden file to dwarf the setup.py's
    6565        # package data handling.
    66         self._hidden_filepath = os.path.join(testfiles_path, '.hidden')
     66        self._hidden_filepath = os.path.join(testfiles_path, str('.hidden'))
    6767        with codecs.open(self._hidden_filepath, 'w', 'utf-8') as f:
    6868            f.write("should be ignored")
    6969        self._backup_filepath = os.path.join(
    70             TEST_ROOT, 'project', 'documents', 'test', 'backup~')
     70            TEST_ROOT, str('project'), str('documents'), str('test'), str('backup~'))
    7171        with codecs.open(self._backup_filepath, 'w', 'utf-8') as f:
    7272            f.write("should be ignored")
    7373
    class BaseCollectionTestCase(BaseStaticFilesTestCase):  
    134134
    135135    def _get_file(self, filepath):
    136136        assert filepath, 'filepath is empty.'
    137         filepath = os.path.join(settings.STATIC_ROOT, filepath)
     137        filepath = os.path.join(settings.STATIC_ROOT, force_str(filepath))
    138138        with codecs.open(filepath, "r", "utf-8") as f:
    139139            return f.read()
    140140
    class TestFindStatic(CollectionTestCase, TestDefaults):  
    207207        out.seek(0)
    208208        lines = [l.strip() for l in out.readlines()]
    209209        self.assertEqual(len(lines), 3)  # three because there is also the "Found <file> here" line
    210         self.assertIn('project', lines[1])
    211         self.assertIn('apps', lines[2])
     210        self.assertIn(str('project'), lines[1])
     211        self.assertIn(str('apps'), lines[2])
    212212
    213213
    214214class TestCollection(CollectionTestCase, TestDefaults):
    class TestCollectionFilesOverride(CollectionTestCase):  
    292292
    293293    """
    294294    def setUp(self):
    295         self.orig_path = os.path.join(TEST_ROOT, 'apps', 'no_label', 'static', 'file2.txt')
     295        self.orig_path = os.path.join(TEST_ROOT, str('apps'), str('no_label'), str('static'), str('file2.txt'))
    296296        # get modification and access times for no_label/static/file2.txt
    297297        self.orig_mtime = os.path.getmtime(self.orig_path)
    298298        self.orig_atime = os.path.getatime(self.orig_path)
    class TestCollectionFilesOverride(CollectionTestCase):  
    301301        # this file will have modification time older than no_label/static/file2.txt
    302302        # anyway it should be taken to STATIC_ROOT because 'test' app is before
    303303        # 'no_label' app in INSTALLED_APPS
    304         self.testfile_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'file2.txt')
     304        self.testfile_path = os.path.join(TEST_ROOT, str('apps'), str('test'), str('static'), str('file2.txt'))
    305305        with open(self.testfile_path, 'w+') as f:
    306306            f.write('duplicate of file2.txt')
    307307        os.utime(self.testfile_path, (self.orig_atime - 1, self.orig_mtime - 1))
    if sys.platform != 'win32':  
    586586            """
    587587            With ``--link``, symbolic links are created.
    588588            """
    589             self.assertTrue(os.path.islink(os.path.join(settings.STATIC_ROOT, 'test.txt')))
     589            self.assertTrue(os.path.islink(os.path.join(settings.STATIC_ROOT, str('test.txt'))))
    590590
    591591
    592592class TestServeStatic(StaticFilesTestCase):
    class FinderTestCase(object):  
    656656    def test_find_first(self):
    657657        src, dst = self.find_first
    658658        found = self.finder.find(src)
     659        # finders currently return paths as unicode strings
     660        dst = path_as_text(dst)
    659661        self.assertEqual(os.path.normcase(found), os.path.normcase(dst))
    660662
    661663    def test_find_all(self):
    662664        src, dst = self.find_all
    663665        found = self.finder.find(src, all=True)
     666        # finders currently return paths as unicode strings
    664667        found = [os.path.normcase(f) for f in found]
    665         dst = [os.path.normcase(d) for d in dst]
     668        dst = [os.path.normcase(path_as_text(d)) for d in dst]
    666669        self.assertEqual(found, dst)
    667670
    668671
    class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase):  
    673676    def setUp(self):
    674677        super(TestFileSystemFinder, self).setUp()
    675678        self.finder = finders.FileSystemFinder()
    676         test_file_path = os.path.join(TEST_ROOT, 'project', 'documents', 'test', 'file.txt')
    677         self.find_first = (os.path.join('test', 'file.txt'), test_file_path)
    678         self.find_all = (os.path.join('test', 'file.txt'), [test_file_path])
     679        test_file_path = os.path.join(TEST_ROOT, str('project'), str('documents'), str('test'), str('file.txt'))
     680        self.find_first = (os.path.join(str('test'), str('file.txt')), test_file_path)
     681        self.find_all = (os.path.join(str('test'), str('file.txt')), [test_file_path])
    679682
    680683
    681684class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase):
    class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase):  
    685688    def setUp(self):
    686689        super(TestAppDirectoriesFinder, self).setUp()
    687690        self.finder = finders.AppDirectoriesFinder()
    688         test_file_path = os.path.join(TEST_ROOT, 'apps', 'test', 'static', 'test', 'file1.txt')
    689         self.find_first = (os.path.join('test', 'file1.txt'), test_file_path)
    690         self.find_all = (os.path.join('test', 'file1.txt'), [test_file_path])
     691        test_file_path = os.path.join(TEST_ROOT, str('apps'), str('test'), str('static'), str('test'), str('file1.txt'))
     692        self.find_first = (os.path.join(str('test'), str('file1.txt')), test_file_path)
     693        self.find_all = (os.path.join(str('test'), str('file1.txt')), [test_file_path])
    691694
    692695
    693696class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase):
    class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase):  
    698701        super(TestDefaultStorageFinder, self).setUp()
    699702        self.finder = finders.DefaultStorageFinder(
    700703            storage=storage.StaticFilesStorage(location=settings.MEDIA_ROOT))
    701         test_file_path = os.path.join(settings.MEDIA_ROOT, 'media-file.txt')
    702         self.find_first = ('media-file.txt', test_file_path)
    703         self.find_all = ('media-file.txt', [test_file_path])
     704        test_file_path = os.path.join(settings.MEDIA_ROOT, str('media-file.txt'))
     705        self.find_first = (str('media-file.txt'), test_file_path)
     706        self.find_all = (str('media-file.txt'), [test_file_path])
    704707
    705708
    706709class TestMiscFinder(TestCase):
  • tests/regressiontests/templates/response.py

    diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
    index a2a76a3..9606333 100644
    a b class SimpleTemplateResponseTest(TestCase):  
    206206
    207207@override_settings(
    208208    TEMPLATE_CONTEXT_PROCESSORS=[test_processor_name],
    209     TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__),'templates')),
     209    TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), str('templates'))),
    210210)
    211211class TemplateResponseTest(TestCase):
    212212
  • tests/regressiontests/templates/tests.py

    diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
    index 65d6e72..d39a5d3 100644
    a b class Templates(TestCase):  
    14121412            ### SSI TAG ########################################################
    14131413
    14141414            # Test normal behavior
    1415             'ssi01': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {}, 'This is for testing an ssi include. {{ test }}\n'),
    1416             'ssi02': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'not_here'), {}, ''),
    1417             'ssi03': ("{%% ssi '%s' %%}" % os.path.join(basedir, 'not_here'), {}, ''),
     1415            'ssi01': ('{%% ssi "%s" %%}' % os.path.join(basedir, str('templates'), str('ssi_include.html')), {}, 'This is for testing an ssi include. {{ test }}\n'),
     1416            'ssi02': ('{%% ssi "%s" %%}' % os.path.join(basedir, str('not_here')), {}, ''),
     1417            'ssi03': ("{%% ssi '%s' %%}" % os.path.join(basedir, str('not_here')), {}, ''),
    14181418
    14191419            # Test passing as a variable
    1420             'ssi04': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': os.path.join(basedir, 'templates', 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'),
    1421             'ssi05': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': 'no_file'}, ''),
     1420            'ssi04': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': os.path.join(basedir, str('templates'), 'ssi_include.html')}, 'This is for testing an ssi include. {{ test }}\n'),
     1421            'ssi05': ('{% load ssi from future %}{% ssi ssi_file %}', {'ssi_file': str('no_file')}, ''),
    14221422
    14231423            # Test parsed output
    1424             'ssi06': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi_include.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
    1425             'ssi07': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'not_here'), {'test': 'Look ma! It parsed!'}, ''),
     1424            'ssi06': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, str('templates'), str('ssi_include.html')), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include. Look ma! It parsed!\n'),
     1425            'ssi07': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, str('not_here')), {'test': 'Look ma! It parsed!'}, ''),
    14261426
    14271427            # Test space in file name
    1428             'ssi08': ('{%% ssi "%s" %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {}, 'This is for testing an ssi include with spaces in its name. {{ test }}\n'),
    1429             'ssi09': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, 'templates', 'ssi include with spaces.html'), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include with spaces in its name. Look ma! It parsed!\n'),
     1428            'ssi08': ('{%% ssi "%s" %%}' % os.path.join(basedir, str('templates'), str('ssi include with spaces.html')), {}, 'This is for testing an ssi include with spaces in its name. {{ test }}\n'),
     1429            'ssi09': ('{%% ssi "%s" parsed %%}' % os.path.join(basedir, str('templates'), str('ssi include with spaces.html')), {'test': 'Look ma! It parsed!'}, 'This is for testing an ssi include with spaces in its name. Look ma! It parsed!\n'),
    14301430
    14311431            ### TEMPLATETAG TAG #######################################################
    14321432            'templatetag01': ('{% templatetag openblock %}', {}, '{%'),
    class TemplateTagLoading(unittest.TestCase):  
    16491649    def setUp(self):
    16501650        self.old_path = sys.path[:]
    16511651        self.old_apps = settings.INSTALLED_APPS
    1652         self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
     1652        self.egg_dir = str('%s/eggs') % os.path.dirname(__file__)
    16531653        self.old_tag_modules = template_base.templatetags_modules
    16541654        template_base.templatetags_modules = []
    16551655
    class TemplateTagLoading(unittest.TestCase):  
    16691669
    16701670    def test_load_error_egg(self):
    16711671        ttext = "{% load broken_egg %}"
    1672         egg_name = '%s/tagsegg.egg' % self.egg_dir
     1672        egg_name = str('%s/tagsegg.egg') % self.egg_dir
    16731673        sys.path.append(egg_name)
    16741674        settings.INSTALLED_APPS = ('tagsegg',)
    16751675        self.assertRaises(template.TemplateSyntaxError, template.Template, ttext)
    class TemplateTagLoading(unittest.TestCase):  
    16811681
    16821682    def test_load_working_egg(self):
    16831683        ttext = "{% load working_egg %}"
    1684         egg_name = '%s/tagsegg.egg' % self.egg_dir
     1684        egg_name = str('%s/tagsegg.egg') % self.egg_dir
    16851685        sys.path.append(egg_name)
    16861686        settings.INSTALLED_APPS = ('tagsegg',)
    16871687        t = template.Template(ttext)
  • tests/regressiontests/test_client_regress/tests.py

    diff --git a/tests/regressiontests/test_client_regress/tests.py b/tests/regressiontests/test_client_regress/tests.py
    index f424321..9c47cc5 100644
    a b from django.http import HttpResponse  
    2121
    2222
    2323@override_settings(
    24     TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'templates'),)
     24    TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), str('templates')),)
    2525)
    2626class AssertContainsTests(TestCase):
    2727    def test_contains(self):
    class TemplateExceptionTests(TestCase):  
    629629                    template_loader.reset()
    630630
    631631    @override_settings(
    632         TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), 'bad_templates'),)
     632        TEMPLATE_DIRS=(os.path.join(os.path.dirname(__file__), str('bad_templates')),)
    633633    )
    634634    def test_bad_404_template(self):
    635635        "Errors found when rendering 404 error templates are re-raised"
  • tests/regressiontests/utils/archive.py

    diff --git a/tests/regressiontests/utils/archive.py b/tests/regressiontests/utils/archive.py
    index 5575f34..6275be7 100644
    a b from django.utils import unittest  
    66from django.utils.archive import Archive, extract
    77
    88
    9 TEST_DIR = os.path.join(os.path.dirname(__file__), 'archives')
     9TEST_DIR = os.path.join(os.path.dirname(__file__), str('archives'))
    1010
    1111
    1212class ArchiveTester(object):
  • tests/regressiontests/utils/module_loading.py

    diff --git a/tests/regressiontests/utils/module_loading.py b/tests/regressiontests/utils/module_loading.py
    index dffb519..80ee706 100644
    a b class DefaultLoader(unittest.TestCase):  
    5050class EggLoader(unittest.TestCase):
    5151    def setUp(self):
    5252        self.old_path = sys.path[:]
    53         self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
     53        self.egg_dir = str('%s/eggs') % os.path.dirname(__file__)
    5454
    5555    def tearDown(self):
    5656        sys.path = self.old_path
  • tests/regressiontests/views/tests/debug.py

    diff --git a/tests/regressiontests/views/tests/debug.py b/tests/regressiontests/views/tests/debug.py
    index e616d18..9a691f7 100644
    a b class ExceptionReportTestMixin(object):  
    306306            self.assertEqual(len(mail.outbox), 1)
    307307            email = mail.outbox[0]
    308308            # Frames vars are never shown in plain text email reports.
    309             self.assertNotIn('cooked_eggs', email.body)
    310             self.assertNotIn('scrambled', email.body)
    311             self.assertNotIn('sauce', email.body)
    312             self.assertNotIn('worcestershire', email.body)
     309            self.assertNotIn(str('cooked_eggs'), email.body)
     310            self.assertNotIn(str('scrambled'), email.body)
     311            self.assertNotIn(str('sauce'), email.body)
     312            self.assertNotIn(str('worcestershire'), email.body)
    313313            if check_for_POST_params:
    314314                for k, v in self.breakfast_data.items():
    315315                    # All POST parameters are shown.
    316                     self.assertIn(k, email.body)
    317                     self.assertIn(v, email.body)
     316                    self.assertIn(str(k), email.body)
     317                    self.assertIn(str(v), email.body)
    318318
    319319    def verify_safe_email(self, view, check_for_POST_params=True):
    320320        """
    class ExceptionReportTestMixin(object):  
    327327            self.assertEqual(len(mail.outbox), 1)
    328328            email = mail.outbox[0]
    329329            # Frames vars are never shown in plain text email reports.
    330             self.assertNotIn('cooked_eggs', email.body)
    331             self.assertNotIn('scrambled', email.body)
    332             self.assertNotIn('sauce', email.body)
    333             self.assertNotIn('worcestershire', email.body)
     330            self.assertNotIn(str('cooked_eggs'), email.body)
     331            self.assertNotIn(str('scrambled'), email.body)
     332            self.assertNotIn(str('sauce'), email.body)
     333            self.assertNotIn(str('worcestershire'), email.body)
    334334            if check_for_POST_params:
    335335                for k, v in self.breakfast_data.items():
    336336                    # All POST parameters' names are shown.
    337                     self.assertIn(k, email.body)
     337                    self.assertIn(str(k), email.body)
    338338                # Non-sensitive POST parameters' values are shown.
    339                 self.assertIn('baked-beans-value', email.body)
    340                 self.assertIn('hash-brown-value', email.body)
     339                self.assertIn(str('baked-beans-value'), email.body)
     340                self.assertIn(str('hash-brown-value'), email.body)
    341341                # Sensitive POST parameters' values are not shown.
    342                 self.assertNotIn('sausage-value', email.body)
    343                 self.assertNotIn('bacon-value', email.body)
     342                self.assertNotIn(str('sausage-value'), email.body)
     343                self.assertNotIn(str('bacon-value'), email.body)
    344344
    345345    def verify_paranoid_email(self, view):
    346346        """
    class ExceptionReportTestMixin(object):  
    353353            self.assertEqual(len(mail.outbox), 1)
    354354            email = mail.outbox[0]
    355355            # Frames vars are never shown in plain text email reports.
    356             self.assertNotIn('cooked_eggs', email.body)
    357             self.assertNotIn('scrambled', email.body)
    358             self.assertNotIn('sauce', email.body)
    359             self.assertNotIn('worcestershire', email.body)
     356            self.assertNotIn(str('cooked_eggs'), email.body)
     357            self.assertNotIn(str('scrambled'), email.body)
     358            self.assertNotIn(str('sauce'), email.body)
     359            self.assertNotIn(str('worcestershire'), email.body)
    360360            for k, v in self.breakfast_data.items():
    361361                # All POST parameters' names are shown.
    362                 self.assertIn(k, email.body)
     362                self.assertIn(str(k), email.body)
    363363                # No POST parameters' values are shown.
    364                 self.assertNotIn(v, email.body)
     364                self.assertNotIn(str(v), email.body)
    365365
    366366
    367367class ExceptionReporterFilterTests(TestCase, ExceptionReportTestMixin):
Back to Top