Ticket #19357: 19357-wip.patch

File 19357-wip.patch, 62.0 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 32ae8ab..50aeaf2 100644
    a b from django.core.management.color import no_style  
    1414from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
    1515      IntegrityError, DatabaseError)
    1616from django.db.models import get_apps
    17 from django.utils.encoding import force_text
     17from django.utils.encoding import force_str, force_text
    1818from itertools import product
    1919
    2020try:
    class Command(BaseCommand):  
    9191
    9292        compression_types = {
    9393            None:   open,
    94             'gz':   gzip.GzipFile,
    95             'zip':  SingleZipReader
     94            str('gz'):   gzip.GzipFile,
     95            str('zip'):  SingleZipReader
    9696        }
    9797        if has_bz2:
    98             compression_types['bz2'] = bz2.BZ2File
     98            compression_types[str('bz2')] = bz2.BZ2File
    9999
    100100        app_module_paths = []
    101101        for app in get_apps():
    class Command(BaseCommand):  
    107107                # It's a models.py module
    108108                app_module_paths.append(app.__file__)
    109109
    110         app_fixtures = [os.path.join(os.path.dirname(path), 'fixtures') for path in app_module_paths]
     110        app_fixtures = [os.path.join(os.path.dirname(path), str('fixtures')) for path in app_module_paths]
    111111
    112112        try:
    113113            with connection.constraint_checks_disabled():
    114114                for fixture_label in fixture_labels:
    115                     parts = fixture_label.split('.')
     115                    parts = force_str(fixture_label).split(str('.'))
    116116
    117117                    if len(parts) > 1 and parts[-1] in compression_types:
    118118                        compression_formats = [parts[-1]]
    class Command(BaseCommand):  
    124124                        fixture_name = parts[0]
    125125                        formats = serializers.get_public_serializer_formats()
    126126                    else:
    127                         fixture_name, format = '.'.join(parts[:-1]), parts[-1]
     127                        fixture_name, format = str('.').join(parts[:-1]), parts[-1]
    128128                        if format in serializers.get_public_serializer_formats():
    129129                            formats = [format]
    130130                        else:
    class Command(BaseCommand):  
    150150                        label_found = False
    151151                        for combo in product([using, None], formats, compression_formats):
    152152                            database, format, compression_format = combo
    153                             file_name = '.'.join(
     153                            file_name = str('.').join(
    154154                                p for p in [
    155155                                    fixture_name, database, format, compression_format
    156156                                ]
  • 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..fec52e8 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, [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
  • 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..c320371 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 DjangoAdminSettingsDirectory(AdminScriptTestCase):  
    554554    def test_setup_environ(self):
    555555        "directory: startapp creates the correct directory"
    556556        args = ['startapp', 'settings_test']
    557         app_path = os.path.join(test_dir, 'settings_test')
     557        app_path = os.path.join(test_dir, str('settings_test'))
    558558        out, err = self.run_django_admin(args, 'regressiontests.settings')
    559559        self.addCleanup(shutil.rmtree, app_path)
    560560        self.assertNoOutput(err)
    class DjangoAdminSettingsDirectory(AdminScriptTestCase):  
    562562
    563563    def test_setup_environ_custom_template(self):
    564564        "directory: startapp creates the correct directory with a custom template"
    565         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'app_template')
     565        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('app_template'))
    566566        args = ['startapp', '--template', template_path, 'custom_settings_test']
    567         app_path = os.path.join(test_dir, 'custom_settings_test')
     567        app_path = os.path.join(test_dir, str('custom_settings_test'))
    568568        out, err = self.run_django_admin(args, 'regressiontests.settings')
    569569        self.addCleanup(shutil.rmtree, app_path)
    570570        self.assertNoOutput(err)
    571571        self.assertTrue(os.path.exists(app_path))
    572         self.assertTrue(os.path.exists(os.path.join(app_path, 'api.py')))
     572        self.assertTrue(os.path.exists(os.path.join(app_path, str('api.py'))))
    573573
    574574    def test_builtin_command(self):
    575575        "directory: django-admin builtin commands fail with an error when no settings provided"
    class ManageSettingsWithImportError(AdminScriptTestCase):  
    994994
    995995    def write_settings_with_import_error(self, filename, apps=None, is_dir=False, sdict=None):
    996996        if is_dir:
    997             settings_dir = os.path.join(test_dir, filename)
     997            settings_dir = os.path.join(test_dir, str(filename))
    998998            os.mkdir(settings_dir)
    999             settings_file_path = os.path.join(settings_dir, '__init__.py')
     999            settings_file_path = os.path.join(settings_dir, str('__init__.py'))
    10001000        else:
    1001             settings_file_path = os.path.join(test_dir, filename)
     1001            settings_file_path = os.path.join(test_dir, str(filename))
    10021002        with open(settings_file_path, 'w') as settings_file:
    10031003            settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
    10041004            settings_file.write('# The next line will cause an import error:\nimport foo42bar\n')
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14111411    def test_simple_project(self):
    14121412        "Make sure the startproject management command creates a project"
    14131413        args = ['startproject', 'testproject']
    1414         testproject_dir = os.path.join(test_dir, 'testproject')
     1414        testproject_dir = os.path.join(test_dir, str('testproject'))
    14151415        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14161416
    14171417        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14261426    def test_invalid_project_name(self):
    14271427        "Make sure the startproject management command validates a project name"
    14281428        args = ['startproject', '7testproject']
    1429         testproject_dir = os.path.join(test_dir, '7testproject')
     1429        testproject_dir = os.path.join(test_dir, str('7testproject'))
    14301430        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14311431
    14321432        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14361436    def test_simple_project_different_directory(self):
    14371437        "Make sure the startproject management command creates a project in a specific directory"
    14381438        args = ['startproject', 'testproject', 'othertestproject']
    1439         testproject_dir = os.path.join(test_dir, 'othertestproject')
     1439        testproject_dir = os.path.join(test_dir, str('othertestproject'))
    14401440        os.mkdir(testproject_dir)
    14411441        self.addCleanup(shutil.rmtree, testproject_dir)
    14421442
    14431443        out, err = self.run_django_admin(args)
    14441444        self.assertNoOutput(err)
    1445         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'manage.py')))
     1445        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('manage.py'))))
    14461446
    14471447        # running again..
    14481448        out, err = self.run_django_admin(args)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    14511451
    14521452    def test_custom_project_template(self):
    14531453        "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')
     1454        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    14551455        args = ['startproject', '--template', template_path, 'customtestproject']
    1456         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1456        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    14571457        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14581458
    14591459        out, err = self.run_django_admin(args)
    14601460        self.assertNoOutput(err)
    14611461        self.assertTrue(os.path.isdir(testproject_dir))
    1462         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
     1462        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
    14631463
    14641464    def test_template_dir_with_trailing_slash(self):
    14651465        "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)
     1466        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template') + os.sep)
    14671467        args = ['startproject', '--template', template_path, 'customtestproject']
    1468         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1468        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    14691469        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14701470
    14711471        out, err = self.run_django_admin(args)
    14721472        self.assertNoOutput(err)
    14731473        self.assertTrue(os.path.isdir(testproject_dir))
    1474         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
     1474        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
    14751475
    14761476    def test_custom_project_template_from_tarball_by_path(self):
    14771477        "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')
     1478        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template.tgz'))
    14791479        args = ['startproject', '--template', template_path, 'tarballtestproject']
    1480         testproject_dir = os.path.join(test_dir, 'tarballtestproject')
     1480        testproject_dir = os.path.join(test_dir, str('tarballtestproject'))
    14811481        self.addCleanup(shutil.rmtree, testproject_dir, True)
    14821482
    14831483        out, err = self.run_django_admin(args)
    14841484        self.assertNoOutput(err)
    14851485        self.assertTrue(os.path.isdir(testproject_dir))
    1486         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1486        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    14871487
    14881488    def test_custom_project_template_from_tarball_to_alternative_location(self):
    14891489        "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')
     1490        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template.tgz'))
    14911491        args = ['startproject', '--template', template_path, 'tarballtestproject', 'altlocation']
    1492         testproject_dir = os.path.join(test_dir, 'altlocation')
     1492        testproject_dir = os.path.join(test_dir, str('altlocation'))
    14931493        os.mkdir(testproject_dir)
    14941494        self.addCleanup(shutil.rmtree, testproject_dir)
    14951495
    14961496        out, err = self.run_django_admin(args)
    14971497        self.assertNoOutput(err)
    14981498        self.assertTrue(os.path.isdir(testproject_dir))
    1499         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1499        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15001500
    15011501    def test_custom_project_template_from_tarball_by_url(self):
    15021502        "Make sure the startproject management command is able to use a different project template from a tarball via a url"
    15031503        template_url = '%s/admin_scripts/custom_templates/project_template.tgz' % self.live_server_url
    15041504
    15051505        args = ['startproject', '--template', template_url, 'urltestproject']
    1506         testproject_dir = os.path.join(test_dir, 'urltestproject')
     1506        testproject_dir = os.path.join(test_dir, str('urltestproject'))
    15071507        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15081508
    15091509        out, err = self.run_django_admin(args)
    15101510        self.assertNoOutput(err)
    15111511        self.assertTrue(os.path.isdir(testproject_dir))
    1512         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1512        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15131513
    15141514    def test_project_template_tarball_url(self):
    15151515        "Startproject management command handles project template tar/zip balls from non-canonical urls"
    15161516        template_url = '%s/admin_scripts/custom_templates/project_template.tgz/' % self.live_server_url
    15171517
    15181518        args = ['startproject', '--template', template_url, 'urltestproject']
    1519         testproject_dir = os.path.join(test_dir, 'urltestproject')
     1519        testproject_dir = os.path.join(test_dir, str('urltestproject'))
    15201520        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15211521
    15221522        out, err = self.run_django_admin(args)
    15231523        self.assertNoOutput(err)
    15241524        self.assertTrue(os.path.isdir(testproject_dir))
    1525         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
     1525        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('run.py'))))
    15261526
    15271527    def test_file_without_extension(self):
    15281528        "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')
     1529        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15301530        args = ['startproject', '--template', template_path, 'customtestproject', '-e', 'txt', '-n', 'Procfile']
    1531         testproject_dir = os.path.join(test_dir, 'customtestproject')
     1531        testproject_dir = os.path.join(test_dir, str('customtestproject'))
    15321532        self.addCleanup(shutil.rmtree, testproject_dir, True)
    15331533
    15341534        out, err = self.run_django_admin(args)
    15351535        self.assertNoOutput(err)
    15361536        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'):
     1537        self.assertTrue(os.path.exists(os.path.join(testproject_dir, str('additional_dir'))))
     1538        base_path = os.path.join(testproject_dir, str('additional_dir'))
     1539        for f in (str('Procfile'), str('additional_file.py'), str('requirements.txt')):
    15401540            self.assertTrue(os.path.exists(os.path.join(base_path, f)))
    15411541            with open(os.path.join(base_path, f)) as fh:
    15421542                self.assertEqual(fh.read(),
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15441544
    15451545    def test_custom_project_template_context_variables(self):
    15461546        "Make sure template context variables are rendered with proper values"
    1547         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1547        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15481548        args = ['startproject', '--template', template_path, 'another_project', 'project_dir']
    1549         testproject_dir = os.path.join(test_dir, 'project_dir')
     1549        testproject_dir = os.path.join(test_dir, str('project_dir'))
    15501550        os.mkdir(testproject_dir)
    15511551        self.addCleanup(shutil.rmtree, testproject_dir)
    15521552        out, err = self.run_django_admin(args)
    15531553        self.assertNoOutput(err)
    1554         test_manage_py = os.path.join(testproject_dir, 'manage.py')
     1554        test_manage_py = os.path.join(testproject_dir, str('manage.py'))
    15551555        with open(test_manage_py, 'r') as fp:
    15561556            content = fp.read()
    1557             self.assertIn("project_name = 'another_project'", content)
    1558             self.assertIn("project_directory = '%s'" % testproject_dir, content)
     1557            self.assertIn(str("project_name = 'another_project'"), content)
     1558            self.assertIn(str("project_directory = '%s'") % testproject_dir, content)
    15591559
    15601560    def test_no_escaping_of_project_variables(self):
    15611561        "Make sure template context variables are not html escaped"
    15621562        # We're using a custom command so we need the alternate settings
    15631563        self.write_settings('alternate_settings.py')
    15641564        self.addCleanup(self.remove_settings, 'alternate_settings.py')
    1565         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1565        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15661566        args = ['custom_startproject', '--template', template_path, 'another_project', 'project_dir', '--extra', '<&>', '--settings=alternate_settings']
    1567         testproject_dir = os.path.join(test_dir, 'project_dir')
     1567        testproject_dir = os.path.join(test_dir, str('project_dir'))
    15681568        os.mkdir(testproject_dir)
    15691569        self.addCleanup(shutil.rmtree, testproject_dir)
    15701570        out, err = self.run_manage(args)
    15711571        self.assertNoOutput(err)
    1572         test_manage_py = os.path.join(testproject_dir, 'additional_dir', 'extra.py')
     1572        test_manage_py = os.path.join(testproject_dir, str('additional_dir'), str('extra.py'))
    15731573        with open(test_manage_py, 'r') as fp:
    15741574            content = fp.read()
    15751575            self.assertIn("<&>", content)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15791579        Make sure an exception is raised when the provided
    15801580        destination directory doesn't exist
    15811581        """
    1582         template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
     1582        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15831583        args = ['startproject', '--template', template_path, 'yet_another_project', 'project_dir2']
    1584         testproject_dir = os.path.join(test_dir, 'project_dir2')
     1584        testproject_dir = os.path.join(test_dir, str('project_dir2'))
    15851585        out, err = self.run_django_admin(args)
    15861586        self.assertNoOutput(out)
    15871587        self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir)
    class StartProject(LiveServerTestCase, AdminScriptTestCase):  
    15891589
    15901590    def test_custom_project_template_with_non_ascii_templates(self):
    15911591        "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')
     1592        template_path = os.path.join(test_dir, str('admin_scripts'), str('custom_templates'), str('project_template'))
    15931593        args = ['startproject', '--template', template_path, '--extension=txt', 'customtestproject']
    15941594        testproject_dir = os.path.join(test_dir, 'customtestproject')
    15951595        self.addCleanup(shutil.rmtree, testproject_dir, True)
  • 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..a67ff38 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
  • 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..ff1766c 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
    2020from django.utils._os import rmtree_errorhandler
    2121from django.utils import six
    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 TestFileSystemFinder(StaticFilesTestCase, FinderTestCase):  
    673673    def setUp(self):
    674674        super(TestFileSystemFinder, self).setUp()
    675675        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])
     676        test_file_path = os.path.join(TEST_ROOT, str('project'), str('documents'), str('test'), str('file.txt'))
     677        self.find_first = (os.path.join(str('test'), str('file.txt')), test_file_path)
     678        self.find_all = (os.path.join(str('test'), str('file.txt')), [test_file_path])
    679679
    680680
    681681class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase):
    class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase):  
    685685    def setUp(self):
    686686        super(TestAppDirectoriesFinder, self).setUp()
    687687        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])
     688        test_file_path = os.path.join(TEST_ROOT, str('apps'), str('test'), str('static'), str('test'), str('file1.txt'))
     689        self.find_first = (os.path.join(str('test'), str('file1.txt')), test_file_path)
     690        self.find_all = (os.path.join(str('test'), str('file1.txt')), [test_file_path])
    691691
    692692
    693693class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase):
    class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase):  
    698698        super(TestDefaultStorageFinder, self).setUp()
    699699        self.finder = finders.DefaultStorageFinder(
    700700            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])
     701        test_file_path = os.path.join(settings.MEDIA_ROOT, str('media-file.txt'))
     702        self.find_first = (str('media-file.txt'), test_file_path)
     703        self.find_all = (str('media-file.txt'), [test_file_path])
    704704
    705705
    706706class 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..3af0088 100644
    a b 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
  • 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
Back to Top