-
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):
|
63 | 63 | @skipIfCustomUser |
64 | 64 | @override_settings( |
65 | 65 | TEMPLATE_DIRS=( |
66 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 66 | os.path.join(os.path.dirname(__file__), str('templates')), |
67 | 67 | ), |
68 | 68 | USE_TZ=False, # required for loading the fixture |
69 | 69 | PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), |
… |
… |
class AuthContextProcessorTests(TestCase):
|
110 | 110 | self.assertContains(response, "Has auth permissions") |
111 | 111 | self.assertContains(response, "Has auth.add_permission permissions") |
112 | 112 | self.assertNotContains(response, "nonexisting") |
113 | | |
| 113 | |
114 | 114 | def test_perm_in_perms_attrs(self): |
115 | 115 | u = User.objects.create_user(username='normal', password='secret') |
116 | 116 | u.user_permissions.add( |
-
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):
|
322 | 322 | self.assertEqual(form.cleaned_data['email'], email) |
323 | 323 | |
324 | 324 | 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')) |
326 | 326 | with self.settings(TEMPLATE_DIRS=(template_path,)): |
327 | 327 | data = {'email': 'testclient@example.com'} |
328 | 328 | form = PasswordResetForm(data) |
-
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
|
27 | 27 | LANGUAGE_CODE='en', |
28 | 28 | TEMPLATE_LOADERS=global_settings.TEMPLATE_LOADERS, |
29 | 29 | TEMPLATE_DIRS=( |
30 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 30 | os.path.join(os.path.dirname(__file__), str('templates')), |
31 | 31 | ), |
32 | 32 | USE_TZ=False, |
33 | 33 | PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',), |
-
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
|
16 | 16 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', |
17 | 17 | ), |
18 | 18 | TEMPLATE_DIRS=( |
19 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 19 | os.path.join(os.path.dirname(__file__), str('templates')), |
20 | 20 | ), |
21 | 21 | SITE_ID=1, |
22 | 22 | ) |
-
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
|
17 | 17 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', |
18 | 18 | ), |
19 | 19 | TEMPLATE_DIRS=( |
20 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 20 | os.path.join(os.path.dirname(__file__), str('templates')), |
21 | 21 | ), |
22 | 22 | SITE_ID=1, |
23 | 23 | ) |
… |
… |
class FlatpageMiddlewareTests(TestCase):
|
95 | 95 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', |
96 | 96 | ), |
97 | 97 | TEMPLATE_DIRS=( |
98 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 98 | os.path.join(os.path.dirname(__file__), str('templates')), |
99 | 99 | ), |
100 | 100 | SITE_ID=1, |
101 | 101 | ) |
-
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
|
16 | 16 | 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', |
17 | 17 | ), |
18 | 18 | TEMPLATE_DIRS=( |
19 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 19 | os.path.join(os.path.dirname(__file__), str('templates')), |
20 | 20 | ), |
21 | 21 | SITE_ID=1, |
22 | 22 | ) |
-
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
|
17 | 17 | # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware' |
18 | 18 | ), |
19 | 19 | TEMPLATE_DIRS=( |
20 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 20 | os.path.join(os.path.dirname(__file__), str('templates')), |
21 | 21 | ), |
22 | 22 | SITE_ID=1, |
23 | 23 | ) |
… |
… |
class FlatpageViewTests(TestCase):
|
84 | 84 | # no 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware' |
85 | 85 | ), |
86 | 86 | TEMPLATE_DIRS=( |
87 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 87 | os.path.join(os.path.dirname(__file__), str('templates')), |
88 | 88 | ), |
89 | 89 | SITE_ID=1, |
90 | 90 | ) |
-
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):
|
36 | 36 | |
37 | 37 | @override_settings( |
38 | 38 | TEMPLATE_DIRS=( |
39 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 39 | os.path.join(os.path.dirname(__file__), str('templates')), |
40 | 40 | ), |
41 | 41 | ) |
42 | 42 | class PreviewTests(TestCase): |
… |
… |
class DummyRequest(http.HttpRequest):
|
214 | 214 | @override_settings( |
215 | 215 | SECRET_KEY="123", |
216 | 216 | TEMPLATE_DIRS=( |
217 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 217 | os.path.join(os.path.dirname(__file__), str('templates')), |
218 | 218 | ), |
219 | 219 | ) |
220 | 220 | class WizardTests(TestCase): |
-
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):
|
74 | 74 | |
75 | 75 | # ticket #19025: `form` should be included in context |
76 | 76 | form = response.context_data['wizard']['form'] |
77 | | self.assertEqual(response.context_data['form'], form) |
| 77 | self.assertEqual(response.context_data['form'], form) |
78 | 78 | |
79 | 79 | def test_form_finish(self): |
80 | 80 | response = self.client.get(self.wizard_url) |
… |
… |
class WizardTestKwargs(TestCase):
|
291 | 291 | self.wizard_step_data[0]['form1-user'] = self.testuser.pk |
292 | 292 | |
293 | 293 | 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')) |
295 | 295 | with self.settings( |
296 | 296 | TEMPLATE_DIRS=list(settings.TEMPLATE_DIRS) + [templates]): |
297 | 297 | response = self.client.get(self.wizard_url) |
-
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,
|
12 | 12 | InterstateProj3D, Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D) |
13 | 13 | |
14 | 14 | |
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') |
| 15 | data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), str('..'), str('data'))) |
| 16 | city_file = os.path.join(data_path, str('cities'), str('cities.shp')) |
| 17 | vrt_file = os.path.join(data_path, str('test_vrt'), str('test_vrt.vrt')) |
18 | 18 | |
19 | 19 | # The coordinates of each city, with Z values corresponding to their |
20 | 20 | # altitude in meters. |
-
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):
|
61 | 61 | from django.contrib.gis.utils import LayerMapping |
62 | 62 | |
63 | 63 | # 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')) |
66 | 66 | co_mapping = {'name' : 'Name', |
67 | 67 | 'state' : 'State', |
68 | 68 | 'mpoly' : 'MULTIPOLYGON', |
-
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 (
|
19 | 19 | city_mapping, co_mapping, cofeat_mapping, inter_mapping) |
20 | 20 | |
21 | 21 | |
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') |
| 22 | shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, str('data'))) |
| 23 | city_shp = os.path.join(shp_path, str('cities'), str('cities.shp')) |
| 24 | co_shp = os.path.join(shp_path, str('counties'), str('counties.shp')) |
| 25 | inter_shp = os.path.join(shp_path, str('interstates'), str('interstates.shp')) |
| 26 | invalid_shp = os.path.join(shp_path, str('invalid'), str('emptypoints.shp')) |
27 | 27 | |
28 | 28 | # Dictionaries to hold what's expected in the county shapefile. |
29 | 29 | NAMES = ['Bexar', 'Galveston', 'Harris', 'Honolulu', 'Pueblo'] |
-
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):
|
29 | 29 | self.assertXMLEqual(response.content.decode('utf-8'), expected_content) |
30 | 30 | |
31 | 31 | @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')),) |
33 | 33 | ) |
34 | 34 | def test_simple_sitemap_custom_index(self): |
35 | 35 | "A simple sitemap index can be rendered with a custom template" |
… |
… |
class HTTPSitemapTests(SitemapTestsBase):
|
64 | 64 | self.assertXMLEqual(response.content.decode('utf-8'), expected_content) |
65 | 65 | |
66 | 66 | @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')),) |
68 | 68 | ) |
69 | 69 | def test_simple_custom_sitemap(self): |
70 | 70 | "A simple sitemap can be rendered with a custom template" |
-
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index 9691b78..507ad1f 100644
a
|
b
|
class CachedFilesMixin(object):
|
106 | 106 | path, filename = os.path.split(clean_name) |
107 | 107 | root, ext = os.path.splitext(filename) |
108 | 108 | 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") % |
111 | 111 | (root, file_hash, ext)) |
112 | 112 | unparsed_name = list(parsed_name) |
113 | 113 | unparsed_name[2] = hashed_name |
… |
… |
class AppStaticStorage(FileSystemStorage):
|
288 | 288 | for the ``static`` directory of it. |
289 | 289 | """ |
290 | 290 | prefix = None |
291 | | source_dir = 'static' |
| 291 | source_dir = str('static') |
292 | 292 | |
293 | 293 | def __init__(self, app, *args, **kwargs): |
294 | 294 | """ |
-
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):
|
14 | 14 | sample.startswith(codecs.BOM_UTF16_BE) |
15 | 15 | |
16 | 16 | def compile_messages(stderr, locale=None): |
17 | | basedirs = [os.path.join('conf', 'locale'), 'locale'] |
| 17 | basedirs = [os.path.join(str('conf'), str('locale')), str('locale')] |
18 | 18 | if os.environ.get('DJANGO_SETTINGS_MODULE'): |
19 | 19 | from django.conf import settings |
20 | 20 | basedirs.extend(settings.LOCALE_PATHS) |
… |
… |
def compile_messages(stderr, locale=None):
|
27 | 27 | |
28 | 28 | for basedir in basedirs: |
29 | 29 | if locale: |
30 | | basedir = os.path.join(basedir, locale, 'LC_MESSAGES') |
| 30 | basedir = os.path.join(basedir, locale, str('LC_MESSAGES')) |
31 | 31 | for dirpath, dirnames, filenames in os.walk(basedir): |
32 | 32 | for f in filenames: |
33 | 33 | 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)) |
35 | 35 | fn = os.path.join(dirpath, f) |
36 | 36 | 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) |
38 | 39 | pf = os.path.splitext(fn)[0] |
39 | 40 | # Store the names of the .mo and .po files in an environment |
40 | 41 | # variable, rather than doing a string replacement into the |
41 | 42 | # command, so that we can take advantage of shell quoting, to |
42 | 43 | # quote any malicious characters/escaping. |
43 | 44 | # 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') |
46 | 47 | if sys.platform == 'win32': # Different shell-variable syntax |
47 | 48 | cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"' |
48 | 49 | else: |
-
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
|
14 | 14 | from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS, |
15 | 15 | IntegrityError, DatabaseError) |
16 | 16 | from django.db.models import get_apps |
17 | | from django.utils.encoding import force_text |
| 17 | from django.utils.encoding import force_str, force_text |
18 | 18 | from itertools import product |
19 | 19 | |
20 | 20 | try: |
… |
… |
class Command(BaseCommand):
|
91 | 91 | |
92 | 92 | compression_types = { |
93 | 93 | None: open, |
94 | | 'gz': gzip.GzipFile, |
95 | | 'zip': SingleZipReader |
| 94 | str('gz'): gzip.GzipFile, |
| 95 | str('zip'): SingleZipReader |
96 | 96 | } |
97 | 97 | if has_bz2: |
98 | | compression_types['bz2'] = bz2.BZ2File |
| 98 | compression_types[str('bz2')] = bz2.BZ2File |
99 | 99 | |
100 | 100 | app_module_paths = [] |
101 | 101 | for app in get_apps(): |
… |
… |
class Command(BaseCommand):
|
107 | 107 | # It's a models.py module |
108 | 108 | app_module_paths.append(app.__file__) |
109 | 109 | |
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] |
111 | 111 | |
112 | 112 | try: |
113 | 113 | with connection.constraint_checks_disabled(): |
114 | 114 | for fixture_label in fixture_labels: |
115 | | parts = fixture_label.split('.') |
| 115 | parts = force_str(fixture_label).split(str('.')) |
116 | 116 | |
117 | 117 | if len(parts) > 1 and parts[-1] in compression_types: |
118 | 118 | compression_formats = [parts[-1]] |
… |
… |
class Command(BaseCommand):
|
124 | 124 | fixture_name = parts[0] |
125 | 125 | formats = serializers.get_public_serializer_formats() |
126 | 126 | else: |
127 | | fixture_name, format = '.'.join(parts[:-1]), parts[-1] |
| 127 | fixture_name, format = str('.').join(parts[:-1]), parts[-1] |
128 | 128 | if format in serializers.get_public_serializer_formats(): |
129 | 129 | formats = [format] |
130 | 130 | else: |
… |
… |
class Command(BaseCommand):
|
150 | 150 | label_found = False |
151 | 151 | for combo in product([using, None], formats, compression_formats): |
152 | 152 | database, format, compression_format = combo |
153 | | file_name = '.'.join( |
| 153 | file_name = str('.').join( |
154 | 154 | p for p in [ |
155 | 155 | fixture_name, database, format, compression_format |
156 | 156 | ] |
-
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
index 78cd17a..e887194 100644
a
|
b
|
def _split_statements(content):
|
159 | 159 | |
160 | 160 | def custom_sql_for_model(model, style, connection): |
161 | 161 | 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'))) |
163 | 163 | output = [] |
164 | 164 | |
165 | 165 | # Post-creation SQL should come before any initial SQL data is loaded. |
… |
… |
def custom_sql_for_model(model, style, connection):
|
171 | 171 | output.extend(f.post_create_sql(style, model._meta.db_table)) |
172 | 172 | |
173 | 173 | # 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())] |
177 | 177 | for sql_file in sql_files: |
178 | 178 | if os.path.exists(sql_file): |
179 | 179 | with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp: |
-
diff --git a/django/db/utils.py b/django/db/utils.py
index a912986..7d6b60d 100644
a
|
b
|
def load_backend(backend_name):
|
27 | 27 | except ImportError as e_user: |
28 | 28 | # The database backend wasn't found. Display a helpful error message |
29 | 29 | # 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')) |
31 | 31 | try: |
32 | 32 | builtin_backends = [ |
33 | 33 | name for _, name, ispkg in pkgutil.iter_modules([backend_dir]) |
-
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):
|
103 | 103 | """ |
104 | 104 | global _translations |
105 | 105 | |
| 106 | language = str(language) |
| 107 | |
106 | 108 | t = _translations.get(language, None) |
107 | 109 | if t is not None: |
108 | 110 | return t |
109 | 111 | |
110 | 112 | from django.conf import settings |
111 | 113 | |
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')) |
113 | 115 | |
114 | 116 | def _fetch(lang, fallback=None): |
115 | 117 | |
… |
… |
def translation(language):
|
123 | 125 | |
124 | 126 | def _translation(path): |
125 | 127 | try: |
126 | | t = gettext_module.translation('django', path, [loc], DjangoTranslation) |
| 128 | t = gettext_module.translation(str('django'), path, [loc], DjangoTranslation) |
127 | 129 | t.set_language(lang) |
128 | 130 | return t |
129 | 131 | except IOError: |
… |
… |
def translation(language):
|
151 | 153 | |
152 | 154 | for appname in reversed(settings.INSTALLED_APPS): |
153 | 155 | 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')) |
155 | 157 | |
156 | 158 | if os.path.isdir(apppath): |
157 | 159 | res = _merge(apppath) |
… |
… |
def all_locale_paths():
|
337 | 339 | """ |
338 | 340 | from django.conf import settings |
339 | 341 | 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')) |
341 | 343 | return [globalpath] + list(settings.LOCALE_PATHS) |
342 | 344 | |
343 | 345 | def check_for_language(lang_code): |
… |
… |
def check_for_language(lang_code):
|
348 | 350 | or session and during format localization. |
349 | 351 | """ |
350 | 352 | 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: |
352 | 354 | return True |
353 | 355 | return False |
354 | 356 | |
… |
… |
def get_language_from_request(request, check_path=False):
|
426 | 428 | if lang.lower() not in supported: |
427 | 429 | continue |
428 | 430 | 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'))): |
430 | 432 | _accepted[normalized] = lang |
431 | 433 | return lang |
432 | 434 | |
-
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):
|
1282 | 1282 | # it comes to validation. This specifically tests that #6302 is fixed for |
1283 | 1283 | # both file fields and image fields. |
1284 | 1284 | |
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: |
1286 | 1286 | 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: |
1288 | 1288 | image_data2 = fp.read() |
1289 | 1289 | |
1290 | 1290 | f = ImageFileForm( |
-
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):
|
27 | 27 | def write_settings(self, filename, apps=None, is_dir=False, sdict=None): |
28 | 28 | test_dir = os.path.dirname(os.path.dirname(__file__)) |
29 | 29 | if is_dir: |
30 | | settings_dir = os.path.join(test_dir, filename) |
| 30 | settings_dir = os.path.join(test_dir, str(filename)) |
31 | 31 | 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')) |
33 | 33 | else: |
34 | | settings_file_path = os.path.join(test_dir, filename) |
| 34 | settings_file_path = os.path.join(test_dir, str(filename)) |
35 | 35 | |
36 | 36 | with open(settings_file_path, 'w') as settings_file: |
37 | 37 | settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n') |
… |
… |
class AdminScriptTestCase(unittest.TestCase):
|
57 | 57 | settings_file.write("%s = %s\n" % (k, v)) |
58 | 58 | |
59 | 59 | 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)) |
61 | 61 | if is_dir: |
62 | 62 | shutil.rmtree(full_name) |
63 | 63 | else: |
… |
… |
class AdminScriptTestCase(unittest.TestCase):
|
68 | 68 | try: |
69 | 69 | if sys.platform.startswith('java'): |
70 | 70 | # 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)) |
72 | 72 | else: |
73 | 73 | # CPython produces module.pyc files |
74 | | os.remove(full_name + 'c') |
| 74 | os.remove(full_name + str('c')) |
75 | 75 | except OSError: |
76 | 76 | pass |
77 | 77 | # 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__')) |
79 | 79 | if os.path.isdir(cache_name): |
80 | 80 | shutil.rmtree(cache_name) |
81 | 81 | |
… |
… |
class AdminScriptTestCase(unittest.TestCase):
|
135 | 135 | |
136 | 136 | def run_django_admin(self, args, settings_file=None): |
137 | 137 | 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) |
139 | 139 | |
140 | 140 | def run_manage(self, args, settings_file=None): |
141 | 141 | def safe_remove(path): |
… |
… |
class AdminScriptTestCase(unittest.TestCase):
|
145 | 145 | pass |
146 | 146 | |
147 | 147 | 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')) |
149 | 149 | |
150 | | test_manage_py = os.path.join(test_dir, 'manage.py') |
| 150 | test_manage_py = os.path.join(test_dir, str('manage.py')) |
151 | 151 | shutil.copyfile(template_manage_py, test_manage_py) |
152 | 152 | |
153 | 153 | with open(test_manage_py, 'r') as fp: |
… |
… |
class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
554 | 554 | def test_setup_environ(self): |
555 | 555 | "directory: startapp creates the correct directory" |
556 | 556 | 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')) |
558 | 558 | out, err = self.run_django_admin(args, 'regressiontests.settings') |
559 | 559 | self.addCleanup(shutil.rmtree, app_path) |
560 | 560 | self.assertNoOutput(err) |
… |
… |
class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
562 | 562 | |
563 | 563 | def test_setup_environ_custom_template(self): |
564 | 564 | "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')) |
566 | 566 | 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')) |
568 | 568 | out, err = self.run_django_admin(args, 'regressiontests.settings') |
569 | 569 | self.addCleanup(shutil.rmtree, app_path) |
570 | 570 | self.assertNoOutput(err) |
571 | 571 | 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')))) |
573 | 573 | |
574 | 574 | def test_builtin_command(self): |
575 | 575 | "directory: django-admin builtin commands fail with an error when no settings provided" |
… |
… |
class ManageSettingsWithImportError(AdminScriptTestCase):
|
994 | 994 | |
995 | 995 | def write_settings_with_import_error(self, filename, apps=None, is_dir=False, sdict=None): |
996 | 996 | if is_dir: |
997 | | settings_dir = os.path.join(test_dir, filename) |
| 997 | settings_dir = os.path.join(test_dir, str(filename)) |
998 | 998 | 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')) |
1000 | 1000 | else: |
1001 | | settings_file_path = os.path.join(test_dir, filename) |
| 1001 | settings_file_path = os.path.join(test_dir, str(filename)) |
1002 | 1002 | with open(settings_file_path, 'w') as settings_file: |
1003 | 1003 | settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n') |
1004 | 1004 | settings_file.write('# The next line will cause an import error:\nimport foo42bar\n') |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1411 | 1411 | def test_simple_project(self): |
1412 | 1412 | "Make sure the startproject management command creates a project" |
1413 | 1413 | args = ['startproject', 'testproject'] |
1414 | | testproject_dir = os.path.join(test_dir, 'testproject') |
| 1414 | testproject_dir = os.path.join(test_dir, str('testproject')) |
1415 | 1415 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1416 | 1416 | |
1417 | 1417 | out, err = self.run_django_admin(args) |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1426 | 1426 | def test_invalid_project_name(self): |
1427 | 1427 | "Make sure the startproject management command validates a project name" |
1428 | 1428 | args = ['startproject', '7testproject'] |
1429 | | testproject_dir = os.path.join(test_dir, '7testproject') |
| 1429 | testproject_dir = os.path.join(test_dir, str('7testproject')) |
1430 | 1430 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1431 | 1431 | |
1432 | 1432 | out, err = self.run_django_admin(args) |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1436 | 1436 | def test_simple_project_different_directory(self): |
1437 | 1437 | "Make sure the startproject management command creates a project in a specific directory" |
1438 | 1438 | args = ['startproject', 'testproject', 'othertestproject'] |
1439 | | testproject_dir = os.path.join(test_dir, 'othertestproject') |
| 1439 | testproject_dir = os.path.join(test_dir, str('othertestproject')) |
1440 | 1440 | os.mkdir(testproject_dir) |
1441 | 1441 | self.addCleanup(shutil.rmtree, testproject_dir) |
1442 | 1442 | |
1443 | 1443 | out, err = self.run_django_admin(args) |
1444 | 1444 | 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')))) |
1446 | 1446 | |
1447 | 1447 | # running again.. |
1448 | 1448 | out, err = self.run_django_admin(args) |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1451 | 1451 | |
1452 | 1452 | def test_custom_project_template(self): |
1453 | 1453 | "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')) |
1455 | 1455 | 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')) |
1457 | 1457 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1458 | 1458 | |
1459 | 1459 | out, err = self.run_django_admin(args) |
1460 | 1460 | self.assertNoOutput(err) |
1461 | 1461 | 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')))) |
1463 | 1463 | |
1464 | 1464 | def test_template_dir_with_trailing_slash(self): |
1465 | 1465 | "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) |
1467 | 1467 | 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')) |
1469 | 1469 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1470 | 1470 | |
1471 | 1471 | out, err = self.run_django_admin(args) |
1472 | 1472 | self.assertNoOutput(err) |
1473 | 1473 | 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')))) |
1475 | 1475 | |
1476 | 1476 | def test_custom_project_template_from_tarball_by_path(self): |
1477 | 1477 | "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')) |
1479 | 1479 | 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')) |
1481 | 1481 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1482 | 1482 | |
1483 | 1483 | out, err = self.run_django_admin(args) |
1484 | 1484 | self.assertNoOutput(err) |
1485 | 1485 | 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')))) |
1487 | 1487 | |
1488 | 1488 | def test_custom_project_template_from_tarball_to_alternative_location(self): |
1489 | 1489 | "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')) |
1491 | 1491 | 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')) |
1493 | 1493 | os.mkdir(testproject_dir) |
1494 | 1494 | self.addCleanup(shutil.rmtree, testproject_dir) |
1495 | 1495 | |
1496 | 1496 | out, err = self.run_django_admin(args) |
1497 | 1497 | self.assertNoOutput(err) |
1498 | 1498 | 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')))) |
1500 | 1500 | |
1501 | 1501 | def test_custom_project_template_from_tarball_by_url(self): |
1502 | 1502 | "Make sure the startproject management command is able to use a different project template from a tarball via a url" |
1503 | 1503 | template_url = '%s/admin_scripts/custom_templates/project_template.tgz' % self.live_server_url |
1504 | 1504 | |
1505 | 1505 | 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')) |
1507 | 1507 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1508 | 1508 | |
1509 | 1509 | out, err = self.run_django_admin(args) |
1510 | 1510 | self.assertNoOutput(err) |
1511 | 1511 | 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')))) |
1513 | 1513 | |
1514 | 1514 | def test_project_template_tarball_url(self): |
1515 | 1515 | "Startproject management command handles project template tar/zip balls from non-canonical urls" |
1516 | 1516 | template_url = '%s/admin_scripts/custom_templates/project_template.tgz/' % self.live_server_url |
1517 | 1517 | |
1518 | 1518 | 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')) |
1520 | 1520 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1521 | 1521 | |
1522 | 1522 | out, err = self.run_django_admin(args) |
1523 | 1523 | self.assertNoOutput(err) |
1524 | 1524 | 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')))) |
1526 | 1526 | |
1527 | 1527 | def test_file_without_extension(self): |
1528 | 1528 | "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')) |
1530 | 1530 | 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')) |
1532 | 1532 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
1533 | 1533 | |
1534 | 1534 | out, err = self.run_django_admin(args) |
1535 | 1535 | self.assertNoOutput(err) |
1536 | 1536 | 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')): |
1540 | 1540 | self.assertTrue(os.path.exists(os.path.join(base_path, f))) |
1541 | 1541 | with open(os.path.join(base_path, f)) as fh: |
1542 | 1542 | self.assertEqual(fh.read(), |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1544 | 1544 | |
1545 | 1545 | def test_custom_project_template_context_variables(self): |
1546 | 1546 | "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')) |
1548 | 1548 | 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')) |
1550 | 1550 | os.mkdir(testproject_dir) |
1551 | 1551 | self.addCleanup(shutil.rmtree, testproject_dir) |
1552 | 1552 | out, err = self.run_django_admin(args) |
1553 | 1553 | 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')) |
1555 | 1555 | with open(test_manage_py, 'r') as fp: |
1556 | 1556 | 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) |
1559 | 1559 | |
1560 | 1560 | def test_no_escaping_of_project_variables(self): |
1561 | 1561 | "Make sure template context variables are not html escaped" |
1562 | 1562 | # We're using a custom command so we need the alternate settings |
1563 | 1563 | self.write_settings('alternate_settings.py') |
1564 | 1564 | 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')) |
1566 | 1566 | 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')) |
1568 | 1568 | os.mkdir(testproject_dir) |
1569 | 1569 | self.addCleanup(shutil.rmtree, testproject_dir) |
1570 | 1570 | out, err = self.run_manage(args) |
1571 | 1571 | 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')) |
1573 | 1573 | with open(test_manage_py, 'r') as fp: |
1574 | 1574 | content = fp.read() |
1575 | 1575 | self.assertIn("<&>", content) |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1579 | 1579 | Make sure an exception is raised when the provided |
1580 | 1580 | destination directory doesn't exist |
1581 | 1581 | """ |
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')) |
1583 | 1583 | 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')) |
1585 | 1585 | out, err = self.run_django_admin(args) |
1586 | 1586 | self.assertNoOutput(out) |
1587 | 1587 | self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir) |
… |
… |
class StartProject(LiveServerTestCase, AdminScriptTestCase):
|
1589 | 1589 | |
1590 | 1590 | def test_custom_project_template_with_non_ascii_templates(self): |
1591 | 1591 | "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')) |
1593 | 1593 | args = ['startproject', '--template', template_path, '--extension=txt', 'customtestproject'] |
1594 | 1594 | testproject_dir = os.path.join(test_dir, 'customtestproject') |
1595 | 1595 | self.addCleanup(shutil.rmtree, testproject_dir, True) |
-
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):
|
633 | 633 | Refs #17515. |
634 | 634 | """ |
635 | 635 | template_dirs = settings.TEMPLATE_DIRS + ( |
636 | | os.path.join(os.path.dirname(__file__), 'templates'),) |
| 636 | os.path.join(os.path.dirname(__file__), str('templates')),) |
637 | 637 | with self.settings(TEMPLATE_DIRS=template_dirs): |
638 | 638 | response = self.client.get("/test_admin/admin/admin_views/color2/") |
639 | 639 | self.assertTrue('custom_filter_template.html' in [t.name for t in response.templates]) |
-
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):
|
13 | 13 | |
14 | 14 | def setUp(self): |
15 | 15 | 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__) |
17 | 17 | |
18 | 18 | # This test adds dummy applications to the app cache. These |
19 | 19 | # need to be removed in order to prevent bad interactions |
-
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):
|
534 | 534 | from django.core.files import images |
535 | 535 | images.open = catching_open |
536 | 536 | 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'))) |
538 | 538 | finally: |
539 | 539 | del images.open |
540 | 540 | self.assertTrue(FileWrapper._closed) |
… |
… |
class InconsistentGetImageDimensionsBug(unittest.TestCase):
|
551 | 551 | """ |
552 | 552 | from django.core.files.images import ImageFile |
553 | 553 | |
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')) |
555 | 555 | image = ImageFile(open(img_path, 'rb')) |
556 | 556 | image_pil = Image.open(img_path) |
557 | 557 | size_1, size_2 = get_image_dimensions(image), get_image_dimensions(image) |
-
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):
|
127 | 127 | """ |
128 | 128 | load_absolute_path = os.path.join( |
129 | 129 | os.path.dirname(__file__), |
130 | | 'fixtures', |
131 | | 'absolute.json' |
| 130 | str('fixtures'), |
| 131 | str('absolute.json') |
132 | 132 | ) |
133 | 133 | management.call_command( |
134 | 134 | 'loaddata', |
… |
… |
class TestFixtures(TestCase):
|
390 | 390 | |
391 | 391 | _cur_dir = os.path.dirname(os.path.abspath(__file__)) |
392 | 392 | |
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'))]) |
395 | 395 | def test_loaddata_forward_refs_split_fixtures(self): |
396 | 396 | """ |
397 | 397 | Regression for #17530 - should be able to cope with forward references |
-
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):
|
992 | 992 | self.assertTrue(got[0].endswith(exp[0])) |
993 | 993 | |
994 | 994 | def test_filepathfield_folders(self): |
995 | | path = os.path.dirname(__file__) + '/filepath_test_files/' |
| 995 | path = os.path.dirname(__file__) + str('/filepath_test_files/') |
996 | 996 | f = FilePathField(path=path, allow_folders=True, allow_files=False) |
997 | 997 | f.choices.sort() |
998 | 998 | expected = [ |
-
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index 2d172ad..9b3d48d 100644
a
|
b
|
class StreamingHttpResponseTests(TestCase):
|
483 | 483 | |
484 | 484 | class FileCloseTests(TestCase): |
485 | 485 | 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')) |
487 | 487 | |
488 | 488 | # file isn't closed until we close the response. |
489 | 489 | file1 = open(filename) |
… |
… |
class FileCloseTests(TestCase):
|
516 | 516 | self.assertTrue(file2.closed) |
517 | 517 | |
518 | 518 | 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')) |
520 | 520 | |
521 | 521 | # file isn't closed until we close the response. |
522 | 522 | file1 = open(filename) |
-
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
|
13 | 13 | @override_settings( |
14 | 14 | USE_I18N=True, |
15 | 15 | LOCALE_PATHS=( |
16 | | os.path.join(os.path.dirname(__file__), 'locale'), |
| 16 | os.path.join(os.path.dirname(__file__), str('locale')), |
17 | 17 | ), |
18 | 18 | LANGUAGE_CODE='en', |
19 | 19 | LANGUAGES=( |
-
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
|
13 | 13 | @override_settings( |
14 | 14 | USE_I18N=True, |
15 | 15 | LOCALE_PATHS=( |
16 | | os.path.join(os.path.dirname(__file__), 'locale'), |
| 16 | os.path.join(os.path.dirname(__file__), str('locale')), |
17 | 17 | ), |
18 | 18 | TEMPLATE_DIRS=( |
19 | | os.path.join(os.path.dirname(__file__), 'templates'), |
| 19 | os.path.join(os.path.dirname(__file__), str('templates')), |
20 | 20 | ), |
21 | 21 | LANGUAGE_CODE='en', |
22 | 22 | LANGUAGES=( |
-
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,
|
46 | 46 | |
47 | 47 | here = os.path.dirname(os.path.abspath(__file__)) |
48 | 48 | extended_locale_paths = settings.LOCALE_PATHS + ( |
49 | | os.path.join(here, 'other', 'locale'), |
| 49 | os.path.join(here, str('other'), str('locale')), |
50 | 50 | ) |
51 | 51 | |
52 | 52 | class TranslationTests(TestCase): |
… |
… |
class TranslationTests(TestCase):
|
266 | 266 | self.assertEqual(trans_real.to_language('en_US'), 'en-us') |
267 | 267 | self.assertEqual(trans_real.to_language('sr_Lat'), 'sr-lat') |
268 | 268 | |
269 | | @override_settings(LOCALE_PATHS=(os.path.join(here, 'other', 'locale'),)) |
| 269 | @override_settings(LOCALE_PATHS=(os.path.join(here, str('other'), str('locale')),)) |
270 | 270 | def test_bad_placeholder_1(self): |
271 | 271 | """ |
272 | 272 | Error in translation file should not crash template rendering |
… |
… |
class TranslationTests(TestCase):
|
278 | 278 | rendered = t.render(Context({'person': 'James'})) |
279 | 279 | self.assertEqual(rendered, 'My name is James.') |
280 | 280 | |
281 | | @override_settings(LOCALE_PATHS=(os.path.join(here, 'other', 'locale'),)) |
| 281 | @override_settings(LOCALE_PATHS=(os.path.join(here, str('other'), str('locale')),)) |
282 | 282 | def test_bad_placeholder_2(self): |
283 | 283 | """ |
284 | 284 | Error in translation file should not crash template rendering |
… |
… |
class FormattingTests(TestCase):
|
666 | 666 | with self.settings(USE_L10N=True, |
667 | 667 | FORMAT_MODULE_PATH='regressiontests.i18n.other.locale'): |
668 | 668 | 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 |
671 | 671 | self.assertEqual(new, old, 'Value returned by get_formats_modules() must be preserved between calls.') |
672 | 672 | |
673 | 673 | def test_localize_templatetag_and_filter(self): |
-
diff --git a/tests/regressiontests/servers/tests.py b/tests/regressiontests/servers/tests.py
index f54e34c..87b7c81 100644
a
|
b
|
from .models import Person
|
22 | 22 | TEST_ROOT = os.path.dirname(__file__) |
23 | 23 | TEST_SETTINGS = { |
24 | 24 | 'MEDIA_URL': '/media/', |
25 | | 'MEDIA_ROOT': os.path.join(TEST_ROOT, 'media'), |
| 25 | 'MEDIA_ROOT': os.path.join(TEST_ROOT, str('media')), |
26 | 26 | 'STATIC_URL': '/static/', |
27 | | 'STATIC_ROOT': os.path.join(TEST_ROOT, 'static'), |
| 27 | 'STATIC_ROOT': os.path.join(TEST_ROOT, str('static')), |
28 | 28 | } |
29 | 29 | |
30 | 30 | |
-
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
|
15 | 15 | from django.core.management import call_command |
16 | 16 | from django.test import TestCase |
17 | 17 | from django.test.utils import override_settings |
18 | | from django.utils.encoding import smart_text |
| 18 | from django.utils.encoding import smart_text, force_str |
19 | 19 | from django.utils.functional import empty |
20 | 20 | from django.utils._os import rmtree_errorhandler |
21 | 21 | from django.utils import six |
… |
… |
TEST_SETTINGS = {
|
27 | 27 | 'DEBUG': True, |
28 | 28 | 'MEDIA_URL': '/media/', |
29 | 29 | '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')), |
32 | 32 | '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'))), |
35 | 35 | ), |
36 | 36 | 'STATICFILES_FINDERS': ( |
37 | 37 | 'django.contrib.staticfiles.finders.FileSystemFinder', |
… |
… |
class BaseStaticFilesTestCase(object):
|
55 | 55 | # run and pick up changes in settings.STATICFILES_DIRS. |
56 | 56 | finders._finders.clear() |
57 | 57 | |
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')) |
59 | 59 | # To make sure SVN doesn't hangs itself with the non-ASCII characters |
60 | 60 | # 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')) |
62 | 62 | with codecs.open(self._nonascii_filepath, 'w', 'utf-8') as f: |
63 | 63 | f.write("\u2297 in the app dir") |
64 | 64 | # And also create the stupid hidden file to dwarf the setup.py's |
65 | 65 | # package data handling. |
66 | | self._hidden_filepath = os.path.join(testfiles_path, '.hidden') |
| 66 | self._hidden_filepath = os.path.join(testfiles_path, str('.hidden')) |
67 | 67 | with codecs.open(self._hidden_filepath, 'w', 'utf-8') as f: |
68 | 68 | f.write("should be ignored") |
69 | 69 | self._backup_filepath = os.path.join( |
70 | | TEST_ROOT, 'project', 'documents', 'test', 'backup~') |
| 70 | TEST_ROOT, str('project'), str('documents'), str('test'), str('backup~')) |
71 | 71 | with codecs.open(self._backup_filepath, 'w', 'utf-8') as f: |
72 | 72 | f.write("should be ignored") |
73 | 73 | |
… |
… |
class BaseCollectionTestCase(BaseStaticFilesTestCase):
|
134 | 134 | |
135 | 135 | def _get_file(self, filepath): |
136 | 136 | 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)) |
138 | 138 | with codecs.open(filepath, "r", "utf-8") as f: |
139 | 139 | return f.read() |
140 | 140 | |
… |
… |
class TestFindStatic(CollectionTestCase, TestDefaults):
|
207 | 207 | out.seek(0) |
208 | 208 | lines = [l.strip() for l in out.readlines()] |
209 | 209 | 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]) |
212 | 212 | |
213 | 213 | |
214 | 214 | class TestCollection(CollectionTestCase, TestDefaults): |
… |
… |
class TestCollectionFilesOverride(CollectionTestCase):
|
292 | 292 | |
293 | 293 | """ |
294 | 294 | 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')) |
296 | 296 | # get modification and access times for no_label/static/file2.txt |
297 | 297 | self.orig_mtime = os.path.getmtime(self.orig_path) |
298 | 298 | self.orig_atime = os.path.getatime(self.orig_path) |
… |
… |
class TestCollectionFilesOverride(CollectionTestCase):
|
301 | 301 | # this file will have modification time older than no_label/static/file2.txt |
302 | 302 | # anyway it should be taken to STATIC_ROOT because 'test' app is before |
303 | 303 | # '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')) |
305 | 305 | with open(self.testfile_path, 'w+') as f: |
306 | 306 | f.write('duplicate of file2.txt') |
307 | 307 | os.utime(self.testfile_path, (self.orig_atime - 1, self.orig_mtime - 1)) |
… |
… |
if sys.platform != 'win32':
|
586 | 586 | """ |
587 | 587 | With ``--link``, symbolic links are created. |
588 | 588 | """ |
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')))) |
590 | 590 | |
591 | 591 | |
592 | 592 | class TestServeStatic(StaticFilesTestCase): |
… |
… |
class TestFileSystemFinder(StaticFilesTestCase, FinderTestCase):
|
673 | 673 | def setUp(self): |
674 | 674 | super(TestFileSystemFinder, self).setUp() |
675 | 675 | 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]) |
679 | 679 | |
680 | 680 | |
681 | 681 | class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase): |
… |
… |
class TestAppDirectoriesFinder(StaticFilesTestCase, FinderTestCase):
|
685 | 685 | def setUp(self): |
686 | 686 | super(TestAppDirectoriesFinder, self).setUp() |
687 | 687 | 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]) |
691 | 691 | |
692 | 692 | |
693 | 693 | class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase): |
… |
… |
class TestDefaultStorageFinder(StaticFilesTestCase, FinderTestCase):
|
698 | 698 | super(TestDefaultStorageFinder, self).setUp() |
699 | 699 | self.finder = finders.DefaultStorageFinder( |
700 | 700 | 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]) |
704 | 704 | |
705 | 705 | |
706 | 706 | class TestMiscFinder(TestCase): |
-
diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
index a2a76a3..9606333 100644
a
|
b
|
class SimpleTemplateResponseTest(TestCase):
|
206 | 206 | |
207 | 207 | @override_settings( |
208 | 208 | 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'))), |
210 | 210 | ) |
211 | 211 | class TemplateResponseTest(TestCase): |
212 | 212 | |
-
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 65d6e72..3af0088 100644
a
|
b
|
class TemplateTagLoading(unittest.TestCase):
|
1649 | 1649 | def setUp(self): |
1650 | 1650 | self.old_path = sys.path[:] |
1651 | 1651 | 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__) |
1653 | 1653 | self.old_tag_modules = template_base.templatetags_modules |
1654 | 1654 | template_base.templatetags_modules = [] |
1655 | 1655 | |
-
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
|
21 | 21 | |
22 | 22 | |
23 | 23 | @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')),) |
25 | 25 | ) |
26 | 26 | class AssertContainsTests(TestCase): |
27 | 27 | def test_contains(self): |
… |
… |
class TemplateExceptionTests(TestCase):
|
629 | 629 | template_loader.reset() |
630 | 630 | |
631 | 631 | @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')),) |
633 | 633 | ) |
634 | 634 | def test_bad_404_template(self): |
635 | 635 | "Errors found when rendering 404 error templates are re-raised" |
-
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
|
6 | 6 | from django.utils.archive import Archive, extract |
7 | 7 | |
8 | 8 | |
9 | | TEST_DIR = os.path.join(os.path.dirname(__file__), 'archives') |
| 9 | TEST_DIR = os.path.join(os.path.dirname(__file__), str('archives')) |
10 | 10 | |
11 | 11 | |
12 | 12 | class ArchiveTester(object): |
-
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):
|
50 | 50 | class EggLoader(unittest.TestCase): |
51 | 51 | def setUp(self): |
52 | 52 | 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__) |
54 | 54 | |
55 | 55 | def tearDown(self): |
56 | 56 | sys.path = self.old_path |