summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-20 08:01:02 -0500
committerGitHub <noreply@github.com>2017-01-20 08:01:02 -0500
commit4e729feaa647547f25debb1cb63dec989dc41a20 (patch)
tree7c7a38c5961bf4daf98a8cb47dc74c769563ffcf /tests
parentec4c1d6717da7a9d09d5b3ce84cccac819bb592c (diff)
Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_scripts/tests.py11
-rw-r--r--tests/admin_scripts/urls.py3
-rw-r--r--tests/admin_views/tests.py5
-rw-r--r--tests/app_loading/tests.py3
-rw-r--r--tests/apps/namespace_package_base/nsapp/apps.py3
-rw-r--r--tests/apps/tests.py7
-rw-r--r--tests/auth_tests/settings.py4
-rw-r--r--tests/auth_tests/test_validators.py3
-rw-r--r--tests/file_storage/tests.py3
-rw-r--r--tests/files/tests.py11
-rw-r--r--tests/fixtures_regress/tests.py5
-rw-r--r--tests/forms_tests/field_tests/test_filepathfield.py15
-rw-r--r--tests/forms_tests/field_tests/test_imagefield.py3
-rw-r--r--tests/forms_tests/tests/test_renderers.py5
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py8
-rw-r--r--tests/gis_tests/geo3d/tests.py3
-rw-r--r--tests/gis_tests/geogapp/tests.py3
-rw-r--r--tests/gis_tests/layermap/tests.py3
-rw-r--r--tests/gis_tests/test_data.py3
-rw-r--r--tests/httpwrappers/tests.py5
-rw-r--r--tests/i18n/contenttypes/tests.py3
-rw-r--r--tests/i18n/patterns/tests.py5
-rw-r--r--tests/i18n/test_percents.py3
-rw-r--r--tests/i18n/tests.py3
-rw-r--r--tests/i18n/utils.py4
-rw-r--r--tests/mail/tests.py3
-rw-r--r--tests/migrations/test_writer.py3
-rw-r--r--tests/model_fields/test_imagefield.py5
-rw-r--r--tests/model_forms/models.py3
-rw-r--r--tests/model_forms/tests.py7
-rw-r--r--tests/project_template/test_settings.py3
-rw-r--r--tests/proxy_model_inheritance/tests.py3
-rwxr-xr-xtests/runtests.py5
-rw-r--r--tests/servers/tests.py3
-rw-r--r--tests/sitemaps_tests/test_http.py5
-rw-r--r--tests/staticfiles_tests/settings.py4
-rw-r--r--tests/staticfiles_tests/test_liveserver.py3
-rw-r--r--tests/template_tests/syntax_tests/i18n/base.py3
-rw-r--r--tests/template_tests/utils.py3
-rw-r--r--tests/test_client_regress/tests.py3
-rw-r--r--tests/test_utils/tests.py4
-rw-r--r--tests/urlpatterns_reverse/test_localeregexprovider.py3
-rw-r--r--tests/user_commands/tests.py3
-rw-r--r--tests/utils_tests/test_archive.py3
-rw-r--r--tests/utils_tests/test_autoreload.py15
-rw-r--r--tests/utils_tests/test_html.py3
-rw-r--r--tests/utils_tests/test_module_loading.py3
-rw-r--r--tests/validators/tests.py3
-rw-r--r--tests/view_tests/tests/test_i18n.py3
-rw-r--r--tests/view_tests/urls.py3
50 files changed, 83 insertions, 140 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 50e034e03e..25e6487a0f 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -26,10 +26,9 @@ from django.db.migrations.recorder import MigrationRecorder
from django.test import (
LiveServerTestCase, SimpleTestCase, TestCase, mock, override_settings,
)
-from django.utils._os import npath, upath
from django.utils.encoding import force_text
-custom_templates_dir = os.path.join(os.path.dirname(upath(__file__)), 'custom_templates')
+custom_templates_dir = os.path.join(os.path.dirname(__file__), 'custom_templates')
PY36 = sys.version_info >= (3, 6)
SYSTEM_CHECK_MSG = 'System check identified no issues'
@@ -128,7 +127,7 @@ class AdminScriptTestCase(unittest.TestCase):
def run_test(self, script, args, settings_file=None, apps=None):
base_dir = os.path.dirname(self.test_dir)
# The base dir for Django's tests is one level up.
- tests_dir = os.path.dirname(os.path.dirname(upath(__file__)))
+ tests_dir = os.path.dirname(os.path.dirname(__file__))
# The base dir for Django is one level above the test dir. We don't use
# `import django` to figure that out, so we don't pick up a Django
# from site-packages or similar.
@@ -152,7 +151,7 @@ class AdminScriptTestCase(unittest.TestCase):
python_path = [base_dir, django_dir, tests_dir]
python_path.extend(ext_backend_base_dirs)
# Use native strings for better compatibility
- test_environ[str(python_path_var_name)] = npath(os.pathsep.join(python_path))
+ test_environ[str(python_path_var_name)] = os.pathsep.join(python_path)
test_environ[str('PYTHONWARNINGS')] = str('')
# Move to the test directory and run
@@ -168,7 +167,7 @@ class AdminScriptTestCase(unittest.TestCase):
return out, err
def run_django_admin(self, args, settings_file=None):
- script_dir = os.path.abspath(os.path.join(os.path.dirname(upath(django.__file__)), 'bin'))
+ script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin'))
return self.run_test(os.path.join(script_dir, 'django-admin.py'), args, settings_file)
def run_manage(self, args, settings_file=None):
@@ -178,7 +177,7 @@ class AdminScriptTestCase(unittest.TestCase):
except OSError:
pass
- conf_dir = os.path.dirname(upath(conf.__file__))
+ conf_dir = os.path.dirname(conf.__file__)
template_manage_py = os.path.join(conf_dir, 'project_template', 'manage.py-tpl')
test_manage_py = os.path.join(self.test_dir, 'manage.py')
diff --git a/tests/admin_scripts/urls.py b/tests/admin_scripts/urls.py
index d258641fbe..edb5e1f3b0 100644
--- a/tests/admin_scripts/urls.py
+++ b/tests/admin_scripts/urls.py
@@ -1,10 +1,9 @@
import os
from django.conf.urls import url
-from django.utils._os import upath
from django.views.static import serve
-here = os.path.dirname(upath(__file__))
+here = os.path.dirname(__file__)
urlpatterns = [
url(r'^custom_templates/(?P<path>.*)$', serve, {
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index ae3ebdd54d..cd423f6a01 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -31,7 +31,6 @@ from django.test import (
from django.test.utils import override_script_prefix, patch_logger
from django.urls import NoReverseMatch, resolve, reverse
from django.utils import formats, translation
-from django.utils._os import upath
from django.utils.cache import get_max_age
from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.encoding import force_bytes, force_text, iri_to_uri
@@ -919,8 +918,8 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
# Put this app's and the shared tests templates dirs in DIRS to take precedence
# over the admin's templates dir.
'DIRS': [
- os.path.join(os.path.dirname(upath(__file__)), 'templates'),
- os.path.join(os.path.dirname(os.path.dirname(upath(__file__))), 'templates'),
+ os.path.join(os.path.dirname(__file__), 'templates'),
+ os.path.join(os.path.dirname(os.path.dirname(__file__)), 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py
index 021e711796..698ce56381 100644
--- a/tests/app_loading/tests.py
+++ b/tests/app_loading/tests.py
@@ -3,13 +3,12 @@ import os
from django.apps import apps
from django.test import SimpleTestCase
from django.test.utils import extend_sys_path
-from django.utils._os import upath
class EggLoadingTest(SimpleTestCase):
def setUp(self):
- self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__))
+ self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
def tearDown(self):
apps.clear_cache()
diff --git a/tests/apps/namespace_package_base/nsapp/apps.py b/tests/apps/namespace_package_base/nsapp/apps.py
index 3e864ae5b4..a878449bf9 100644
--- a/tests/apps/namespace_package_base/nsapp/apps.py
+++ b/tests/apps/namespace_package_base/nsapp/apps.py
@@ -1,9 +1,8 @@
import os
from django.apps import AppConfig
-from django.utils._os import upath
class NSAppConfig(AppConfig):
name = 'nsapp'
- path = upath(os.path.dirname(__file__))
+ path = os.path.dirname(__file__)
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index 0263af897f..76bac55a83 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -7,7 +7,6 @@ from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from django.db import models
from django.test import SimpleTestCase, override_settings
from django.test.utils import extend_sys_path, isolate_apps
-from django.utils._os import upath
from .default_config_app.apps import CustomConfig
from .models import SoAlternative, TotallyNormal, new_apps
@@ -29,7 +28,7 @@ SOME_INSTALLED_APPS_NAMES = [
'django.contrib.auth',
] + SOME_INSTALLED_APPS[2:]
-HERE = os.path.dirname(upath(__file__))
+HERE = os.path.dirname(__file__)
class AppsTests(SimpleTestCase):
@@ -385,7 +384,7 @@ class NamespacePackageAppTests(SimpleTestCase):
with extend_sys_path(self.base_location):
with self.settings(INSTALLED_APPS=['nsapp']):
app_config = apps.get_app_config('nsapp')
- self.assertEqual(app_config.path, upath(self.app_path))
+ self.assertEqual(app_config.path, self.app_path)
def test_multiple_paths(self):
"""
@@ -410,4 +409,4 @@ class NamespacePackageAppTests(SimpleTestCase):
with extend_sys_path(self.base_location, self.other_location):
with self.settings(INSTALLED_APPS=['nsapp.apps.NSAppConfig']):
app_config = apps.get_app_config('nsapp')
- self.assertEqual(app_config.path, upath(self.app_path))
+ self.assertEqual(app_config.path, self.app_path)
diff --git a/tests/auth_tests/settings.py b/tests/auth_tests/settings.py
index 8c295387c4..9fd71dfe87 100644
--- a/tests/auth_tests/settings.py
+++ b/tests/auth_tests/settings.py
@@ -1,7 +1,5 @@
import os
-from django.utils._os import upath
-
AUTH_MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -9,7 +7,7 @@ AUTH_MIDDLEWARE = [
AUTH_TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
+ 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py
index 19d75c8d30..e9dc1f7f3f 100644
--- a/tests/auth_tests/test_validators.py
+++ b/tests/auth_tests/test_validators.py
@@ -13,7 +13,6 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase, override_settings
from django.test.utils import isolate_apps
-from django.utils._os import upath
@override_settings(AUTH_PASSWORD_VALIDATORS=[
@@ -171,7 +170,7 @@ class CommonPasswordValidatorTest(TestCase):
self.assertEqual(cm.exception.messages, [expected_error])
def test_validate_custom_list(self):
- path = os.path.join(os.path.dirname(os.path.realpath(upath(__file__))), 'common-passwords-custom.txt')
+ path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'common-passwords-custom.txt')
validator = CommonPasswordValidator(password_list_path=path)
expected_error = "This password is too common."
self.assertIsNone(validator.validate('a-safe-password'))
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 7912eb7efa..d33ca67c33 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -24,7 +24,6 @@ from django.test import (
from django.test.utils import requires_tz_support
from django.urls import NoReverseMatch, reverse_lazy
from django.utils import timezone
-from django.utils._os import upath
from .models import Storage, temp_storage, temp_storage_location
@@ -108,7 +107,7 @@ class FileStorageTests(SimpleTestCase):
"""
storage = self.storage_class(location='')
self.assertEqual(storage.base_location, '')
- self.assertEqual(storage.location, upath(os.getcwd()))
+ self.assertEqual(storage.location, os.getcwd())
def test_file_access_options(self):
"""
diff --git a/tests/files/tests.py b/tests/files/tests.py
index 4515b1cab1..7323b6987e 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -11,7 +11,6 @@ from django.core.files.move import file_move_safe
from django.core.files.temp import NamedTemporaryFile
from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
from django.test import mock
-from django.utils._os import upath
try:
from PIL import Image
@@ -227,7 +226,7 @@ class DimensionClosingBug(unittest.TestCase):
images.open = catching_open
try:
- images.get_image_dimensions(os.path.join(os.path.dirname(upath(__file__)), "test1.png"))
+ images.get_image_dimensions(os.path.join(os.path.dirname(__file__), "test1.png"))
finally:
del images.open
self.assertTrue(FileWrapper._closed)
@@ -243,7 +242,7 @@ class InconsistentGetImageDimensionsBug(unittest.TestCase):
"""
Multiple calls of get_image_dimensions() should return the same size.
"""
- img_path = os.path.join(os.path.dirname(upath(__file__)), "test.png")
+ img_path = os.path.join(os.path.dirname(__file__), "test.png")
with open(img_path, 'rb') as fh:
image = images.ImageFile(fh)
image_pil = Image.open(fh)
@@ -258,7 +257,7 @@ class InconsistentGetImageDimensionsBug(unittest.TestCase):
Regression test for #19457
get_image_dimensions fails on some pngs, while Image.size is working good on them
"""
- img_path = os.path.join(os.path.dirname(upath(__file__)), "magic.png")
+ img_path = os.path.join(os.path.dirname(__file__), "magic.png")
size = images.get_image_dimensions(img_path)
with open(img_path, 'rb') as fh:
self.assertEqual(size, Image.open(fh).size)
@@ -275,7 +274,7 @@ class GetImageDimensionsTests(unittest.TestCase):
brokenimg.png is not a valid image and it has been generated by:
$ echo "123" > brokenimg.png
"""
- img_path = os.path.join(os.path.dirname(upath(__file__)), "brokenimg.png")
+ img_path = os.path.join(os.path.dirname(__file__), "brokenimg.png")
with open(img_path, 'rb') as fh:
size = images.get_image_dimensions(fh)
self.assertEqual(size, (None, None))
@@ -288,7 +287,7 @@ class GetImageDimensionsTests(unittest.TestCase):
Emulates the Parser feed error. Since the error is raised on every feed
attempt, the resulting image size should be invalid: (None, None).
"""
- img_path = os.path.join(os.path.dirname(upath(__file__)), "test.png")
+ img_path = os.path.join(os.path.dirname(__file__), "test.png")
with mock.patch('PIL.ImageFile.Parser.feed', side_effect=struct.error):
with open(img_path, 'rb') as fh:
size = images.get_image_dimensions(fh)
diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py
index 538fee55a2..3ca5084995 100644
--- a/tests/fixtures_regress/tests.py
+++ b/tests/fixtures_regress/tests.py
@@ -14,7 +14,6 @@ from django.test import (
TestCase, TransactionTestCase, override_settings, skipIfDBFeature,
skipUnlessDBFeature,
)
-from django.utils._os import upath
from .models import (
Absolute, Animal, Article, Book, Child, Circle1, Circle2, Circle3,
@@ -26,7 +25,7 @@ from .models import (
Person, RefToNKChild, Store, Stuff, Thingy, Widget,
)
-_cur_dir = os.path.dirname(os.path.abspath(upath(__file__)))
+_cur_dir = os.path.dirname(os.path.abspath(__file__))
class TestFixtures(TestCase):
@@ -142,7 +141,7 @@ class TestFixtures(TestCase):
fixture directory.
"""
load_absolute_path = os.path.join(
- os.path.dirname(upath(__file__)),
+ os.path.dirname(__file__),
'fixtures',
'absolute.json'
)
diff --git a/tests/forms_tests/field_tests/test_filepathfield.py b/tests/forms_tests/field_tests/test_filepathfield.py
index 71164b5b7a..cbdf97b4c2 100644
--- a/tests/forms_tests/field_tests/test_filepathfield.py
+++ b/tests/forms_tests/field_tests/test_filepathfield.py
@@ -2,7 +2,6 @@ import os.path
from django.forms import FilePathField, ValidationError, forms
from django.test import SimpleTestCase
-from django.utils._os import upath
def fix_os_paths(x):
@@ -19,13 +18,11 @@ def fix_os_paths(x):
class FilePathFieldTest(SimpleTestCase):
def test_filepathfield_1(self):
- path = os.path.abspath(upath(forms.__file__))
- path = os.path.dirname(path) + '/'
+ path = os.path.dirname(os.path.abspath(forms.__file__)) + '/'
self.assertTrue(fix_os_paths(path).endswith('/django/forms/'))
def test_filepathfield_2(self):
- path = upath(forms.__file__)
- path = os.path.dirname(os.path.abspath(path)) + '/'
+ path = os.path.dirname(os.path.abspath(forms.__file__)) + '/'
f = FilePathField(path=path)
f.choices = [p for p in f.choices if p[0].endswith('.py')]
f.choices.sort()
@@ -49,8 +46,7 @@ class FilePathFieldTest(SimpleTestCase):
self.assertTrue(fix_os_paths(f.clean(path + 'fields.py')).endswith('/django/forms/fields.py'))
def test_filepathfield_3(self):
- path = upath(forms.__file__)
- path = os.path.dirname(os.path.abspath(path)) + '/'
+ path = os.path.dirname(os.path.abspath(forms.__file__)) + '/'
f = FilePathField(path=path, match=r'^.*?\.py$')
f.choices.sort()
expected = [
@@ -69,8 +65,7 @@ class FilePathFieldTest(SimpleTestCase):
self.assertTrue(got[0].endswith(exp[0]))
def test_filepathfield_4(self):
- path = os.path.abspath(upath(forms.__file__))
- path = os.path.dirname(path) + '/'
+ path = os.path.dirname(os.path.abspath(forms.__file__)) + '/'
f = FilePathField(path=path, recursive=True, match=r'^.*?\.py$')
f.choices.sort()
expected = [
@@ -89,7 +84,7 @@ class FilePathFieldTest(SimpleTestCase):
self.assertTrue(got[0].endswith(exp[0]))
def test_filepathfield_folders(self):
- path = os.path.abspath(os.path.join(upath(__file__), '..', '..')) + '/tests/filepath_test_files/'
+ path = os.path.abspath(os.path.join(__file__, '..', '..')) + '/tests/filepath_test_files/'
f = FilePathField(path=path, allow_folders=True, allow_files=False)
f.choices.sort()
expected = [
diff --git a/tests/forms_tests/field_tests/test_imagefield.py b/tests/forms_tests/field_tests/test_imagefield.py
index 326735bf60..6fb4bed03c 100644
--- a/tests/forms_tests/field_tests/test_imagefield.py
+++ b/tests/forms_tests/field_tests/test_imagefield.py
@@ -4,7 +4,6 @@ import unittest
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import ImageField
from django.test import SimpleTestCase
-from django.utils._os import upath
try:
from PIL import Image
@@ -13,7 +12,7 @@ except ImportError:
def get_img_path(path):
- return os.path.join(os.path.abspath(os.path.join(upath(__file__), '..', '..')), 'tests', path)
+ return os.path.join(os.path.abspath(os.path.join(__file__, '..', '..')), 'tests', path)
@unittest.skipUnless(Image, "Pillow is required to test ImageField")
diff --git a/tests/forms_tests/tests/test_renderers.py b/tests/forms_tests/tests/test_renderers.py
index df9c9cf367..47452fa489 100644
--- a/tests/forms_tests/tests/test_renderers.py
+++ b/tests/forms_tests/tests/test_renderers.py
@@ -5,7 +5,6 @@ from django.forms.renderers import (
BaseRenderer, DjangoTemplates, Jinja2, TemplatesSetting,
)
from django.test import SimpleTestCase
-from django.utils._os import upath
try:
import jinja2
@@ -23,12 +22,12 @@ class SharedTests:
tpl = renderer.get_template('forms_tests/custom_widget.html')
expected_path = os.path.abspath(
os.path.join(
- upath(os.path.dirname(__file__)),
+ os.path.dirname(__file__),
'..',
self.expected_widget_dir + '/forms_tests/custom_widget.html',
)
)
- self.assertEqual(upath(tpl.origin.name), expected_path)
+ self.assertEqual(tpl.origin.name, expected_path)
class BaseTemplateRendererTests(SimpleTestCase):
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index 1a2753c717..cd850af9a1 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -49,7 +49,6 @@ from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.shortcuts import numpy
from django.test import SimpleTestCase
-from django.utils._os import upath
from ..data.rasters.textrasters import JSON_RASTER
@@ -64,8 +63,7 @@ class GDALRasterTests(SimpleTestCase):
Test a GDALRaster instance created from a file (GeoTiff).
"""
def setUp(self):
- self.rs_path = os.path.join(os.path.dirname(upath(__file__)),
- '../data/rasters/raster.tif')
+ self.rs_path = os.path.join(os.path.dirname(__file__), '../data/rasters/raster.tif')
self.rs = GDALRaster(self.rs_path)
def test_rs_name_repr(self):
@@ -388,7 +386,7 @@ class GDALRasterTests(SimpleTestCase):
@unittest.skipUnless(HAS_GDAL, "GDAL is required")
class GDALBandTests(SimpleTestCase):
def setUp(self):
- self.rs_path = os.path.join(os.path.dirname(upath(__file__)), '../data/rasters/raster.tif')
+ self.rs_path = os.path.join(os.path.dirname(__file__), '../data/rasters/raster.tif')
rs = GDALRaster(self.rs_path)
self.band = rs.bands[0]
@@ -403,7 +401,7 @@ class GDALBandTests(SimpleTestCase):
if numpy:
data = self.band.data()
assert_array = numpy.loadtxt(
- os.path.join(os.path.dirname(upath(__file__)), '../data/rasters/raster.numpy.txt')
+ os.path.join(os.path.dirname(__file__), '../data/rasters/raster.numpy.txt')
)
numpy.testing.assert_equal(data, assert_array)
self.assertEqual(data.shape, (self.band.height, self.band.width))
diff --git a/tests/gis_tests/geo3d/tests.py b/tests/gis_tests/geo3d/tests.py
index 72be664014..f05e2e35ce 100644
--- a/tests/gis_tests/geo3d/tests.py
+++ b/tests/gis_tests/geo3d/tests.py
@@ -7,14 +7,13 @@ from django.contrib.gis.db.models.functions import (
)
from django.contrib.gis.geos import GEOSGeometry, LineString, Point, Polygon
from django.test import TestCase, skipUnlessDBFeature
-from django.utils._os import upath
from .models import (
City3D, Interstate2D, Interstate3D, InterstateProj2D, InterstateProj3D,
MultiPoint3D, Point2D, Point3D, Polygon2D, Polygon3D,
)
-data_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), '..', 'data'))
+data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
city_file = os.path.join(data_path, 'cities', 'cities.shp')
vrt_file = os.path.join(data_path, 'test_vrt', 'test_vrt.vrt')
diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py
index 7112f0238e..551fda4b83 100644
--- a/tests/gis_tests/geogapp/tests.py
+++ b/tests/gis_tests/geogapp/tests.py
@@ -10,7 +10,6 @@ from django.contrib.gis.measure import D
from django.db import connection
from django.db.models.functions import Cast
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
-from django.utils._os import upath
from ..utils import oracle, postgis, spatialite
from .models import City, County, Zipcode
@@ -66,7 +65,7 @@ class GeographyTest(TestCase):
from django.contrib.gis.utils import LayerMapping
# Getting the shapefile and mapping dictionary.
- shp_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), '..', 'data'))
+ shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
co_mapping = {'name': 'Name',
'state': 'State',
diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py
index ce4b0c90d5..82bc534fbf 100644
--- a/tests/gis_tests/layermap/tests.py
+++ b/tests/gis_tests/layermap/tests.py
@@ -8,7 +8,6 @@ from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geos import HAS_GEOS
from django.db import connection
from django.test import TestCase, override_settings, skipUnlessDBFeature
-from django.utils._os import upath
if HAS_GEOS and HAS_GDAL:
from django.contrib.gis.utils.layermapping import (
@@ -23,7 +22,7 @@ if HAS_GEOS and HAS_GDAL:
)
-shp_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), os.pardir, 'data'))
+shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
co_shp = os.path.join(shp_path, 'counties', 'counties.shp')
inter_shp = os.path.join(shp_path, 'interstates', 'interstates.shp')
diff --git a/tests/gis_tests/test_data.py b/tests/gis_tests/test_data.py
index 23df42c007..4bec3c677e 100644
--- a/tests/gis_tests/test_data.py
+++ b/tests/gis_tests/test_data.py
@@ -5,11 +5,10 @@ for the GEOS and GDAL tests.
import json
import os
-from django.utils._os import upath
from django.utils.functional import cached_property
# Path where reference test data is located.
-TEST_DATA = os.path.join(os.path.dirname(upath(__file__)), 'data')
+TEST_DATA = os.path.join(os.path.dirname(__file__), 'data')
def tuplize(seq):
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index fe2ad1a216..612cbb45ef 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -16,7 +16,6 @@ from django.http import (
StreamingHttpResponse, parse_cookie,
)
from django.test import SimpleTestCase
-from django.utils._os import upath
from django.utils.functional import lazystr
@@ -634,7 +633,7 @@ class FileCloseTests(SimpleTestCase):
request_finished.connect(close_old_connections)
def test_response(self):
- filename = os.path.join(os.path.dirname(upath(__file__)), 'abc.txt')
+ filename = os.path.join(os.path.dirname(__file__), 'abc.txt')
# file isn't closed until we close the response.
file1 = open(filename)
@@ -652,7 +651,7 @@ class FileCloseTests(SimpleTestCase):
self.assertTrue(file2.closed)
def test_streaming_response(self):
- filename = os.path.join(os.path.dirname(upath(__file__)), 'abc.txt')
+ filename = os.path.join(os.path.dirname(__file__), 'abc.txt')
# file isn't closed until we close the response.
file1 = open(filename)
diff --git a/tests/i18n/contenttypes/tests.py b/tests/i18n/contenttypes/tests.py
index 94f355aba7..e2b7157692 100644
--- a/tests/i18n/contenttypes/tests.py
+++ b/tests/i18n/contenttypes/tests.py
@@ -3,13 +3,12 @@ import os
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
from django.utils import translation
-from django.utils._os import upath
@override_settings(
USE_I18N=True,
LOCALE_PATHS=[
- os.path.join(os.path.dirname(upath(__file__)), 'locale'),
+ os.path.join(os.path.dirname(__file__), 'locale'),
],
LANGUAGE_CODE='en',
LANGUAGES=[
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index a889125e82..35b879d11a 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -10,7 +10,6 @@ from django.test.client import RequestFactory
from django.test.utils import override_script_prefix
from django.urls import clear_url_caches, reverse, translate_url
from django.utils import translation
-from django.utils._os import upath
class PermanentRedirectLocaleMiddleWare(LocaleMiddleware):
@@ -20,7 +19,7 @@ class PermanentRedirectLocaleMiddleWare(LocaleMiddleware):
@override_settings(
USE_I18N=True,
LOCALE_PATHS=[
- os.path.join(os.path.dirname(upath(__file__)), 'locale'),
+ os.path.join(os.path.dirname(__file__), 'locale'),
],
LANGUAGE_CODE='en-us',
LANGUAGES=[
@@ -35,7 +34,7 @@ class PermanentRedirectLocaleMiddleWare(LocaleMiddleware):
ROOT_URLCONF='i18n.patterns.urls.default',
TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
+ 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.i18n',
diff --git a/tests/i18n/test_percents.py b/tests/i18n/test_percents.py
index 48d62ada05..22ea73b790 100644
--- a/tests/i18n/test_percents.py
+++ b/tests/i18n/test_percents.py
@@ -2,13 +2,12 @@ import os
from django.template import Context, Template
from django.test import SimpleTestCase, override_settings
-from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.translation import activate, get_language, trans_real
from .utils import POFileAssertionMixin
-SAMPLEPROJECT_DIR = os.path.join(os.path.dirname(os.path.abspath(upath(__file__))), 'sampleproject')
+SAMPLEPROJECT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'sampleproject')
SAMPLEPROJECT_LOCALE = os.path.join(SAMPLEPROJECT_DIR, 'locale')
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index c3acdfe2fc..181de62bea 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -15,7 +15,6 @@ from django.test import (
RequestFactory, SimpleTestCase, TestCase, override_settings,
)
from django.utils import translation
-from django.utils._os import upath
from django.utils.formats import (
date_format, get_format, get_format_modules, iter_format_modules, localize,
localize_input, reset_format_cache, sanitize_separators, time_format,
@@ -32,7 +31,7 @@ from django.utils.translation import (
from .forms import CompanyForm, I18nForm, SelectDateForm
from .models import Company, TestModel
-here = os.path.dirname(os.path.abspath(upath(__file__)))
+here = os.path.dirname(os.path.abspath(__file__))
extended_locale_paths = settings.LOCALE_PATHS + [
os.path.join(here, 'other', 'locale'),
]
diff --git a/tests/i18n/utils.py b/tests/i18n/utils.py
index b2267cd3eb..2bf4f3e63e 100644
--- a/tests/i18n/utils.py
+++ b/tests/i18n/utils.py
@@ -3,9 +3,7 @@ import re
import shutil
import tempfile
-from django.utils._os import upath
-
-source_code_dir = os.path.dirname(upath(__file__))
+source_code_dir = os.path.dirname(__file__)
def copytree(src, dst):
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 8ba4d64423..8019f3ccf8 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -25,7 +25,6 @@ from django.core.mail.backends import console, dummy, filebased, locmem, smtp
from django.core.mail.message import BadHeaderError, sanitize_address
from django.test import SimpleTestCase, override_settings
from django.test.utils import requires_tz_support
-from django.utils._os import upath
from django.utils.encoding import force_bytes, force_text
from django.utils.translation import ugettext_lazy
@@ -411,7 +410,7 @@ class MailTests(HeadersCheckMixin, SimpleTestCase):
email = EmailMessage('subject', 'body', 'from@example.com', ['to@example.com'])
self.assertEqual(mimetypes.guess_type(basename)[0], real_mimetype)
self.assertEqual(email.attachments, [])
- file_path = os.path.join(os.path.dirname(upath(__file__)), 'attachments', basename)
+ file_path = os.path.join(os.path.dirname(__file__), 'attachments', basename)
email.attach_file(file_path, mimetype=mimetype)
self.assertEqual(len(email.attachments), 1)
self.assertIn(basename, email.attachments[0])
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 83de774aee..0528583fcc 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -22,7 +22,6 @@ from django.db.migrations.writer import (
)
from django.test import SimpleTestCase, ignore_warnings, mock
from django.utils import datetime_safe
-from django.utils._os import upath
from django.utils.deconstruct import deconstructible
from django.utils.functional import SimpleLazyObject
from django.utils.timezone import FixedOffset, get_default_timezone, utc
@@ -576,7 +575,7 @@ class WriterTests(SimpleTestCase):
'migrations.migrations_test_apps.without_init_file',
]
- base_dir = os.path.dirname(os.path.dirname(upath(__file__)))
+ base_dir = os.path.dirname(os.path.dirname(__file__))
for app in test_apps:
with self.modify_settings(INSTALLED_APPS={'append': app}):
diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py
index 92985a99d9..96fa8c839b 100644
--- a/tests/model_fields/test_imagefield.py
+++ b/tests/model_fields/test_imagefield.py
@@ -7,7 +7,6 @@ from django.core.files import File
from django.core.files.images import ImageFile
from django.test import TestCase
from django.test.testcases import SerializeMixin
-from django.utils._os import upath
try:
from .models import Image
@@ -51,10 +50,10 @@ class ImageFieldTestMixin(SerializeMixin):
shutil.rmtree(temp_storage_dir)
os.mkdir(temp_storage_dir)
- file_path1 = os.path.join(os.path.dirname(upath(__file__)), "4x8.png")
+ file_path1 = os.path.join(os.path.dirname(__file__), '4x8.png')
self.file1 = self.File(open(file_path1, 'rb'), name='4x8.png')
- file_path2 = os.path.join(os.path.dirname(upath(__file__)), "8x4.png")
+ file_path2 = os.path.join(os.path.dirname(__file__), '8x4.png')
self.file2 = self.File(open(file_path2, 'rb'), name='8x4.png')
def tearDown(self):
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
index f85ae8e1fd..c1c97270fc 100644
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -15,7 +15,6 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
-from django.utils._os import upath
temp_storage_dir = tempfile.mkdtemp()
temp_storage = FileSystemStorage(temp_storage_dir)
@@ -160,7 +159,7 @@ class CustomFF(models.Model):
class FilePathModel(models.Model):
- path = models.FilePathField(path=os.path.dirname(upath(__file__)), match=r".*\.py$", blank=True)
+ path = models.FilePathField(path=os.path.dirname(__file__), match=r".*\.py$", blank=True)
try:
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 108c917587..3c8f7ed108 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -17,7 +17,6 @@ from django.forms.models import (
)
from django.template import Context, Template
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
-from django.utils._os import upath
from .models import (
Article, ArticleStatus, Author, Author1, Award, BetterWriter, BigInt, Book,
@@ -2221,7 +2220,7 @@ class FileAndImageFieldTests(TestCase):
fields = '__all__'
# Grab an image for testing.
- filename = os.path.join(os.path.dirname(upath(__file__)), "test.png")
+ filename = os.path.join(os.path.dirname(__file__), 'test.png')
with open(filename, "rb") as fp:
img = fp.read()
@@ -2260,9 +2259,9 @@ class FileAndImageFieldTests(TestCase):
# it comes to validation. This specifically tests that #6302 is fixed for
# both file fields and image fields.
- with open(os.path.join(os.path.dirname(upath(__file__)), "test.png"), 'rb') as fp:
+ with open(os.path.join(os.path.dirname(__file__), 'test.png'), 'rb') as fp:
image_data = fp.read()
- with open(os.path.join(os.path.dirname(upath(__file__)), "test2.png"), 'rb') as fp:
+ with open(os.path.join(os.path.dirname(__file__), 'test2.png'), 'rb') as fp:
image_data2 = fp.read()
f = ImageFileForm(
diff --git a/tests/project_template/test_settings.py b/tests/project_template/test_settings.py
index 5623df320b..50fa31d8f3 100644
--- a/tests/project_template/test_settings.py
+++ b/tests/project_template/test_settings.py
@@ -3,14 +3,13 @@ import shutil
from django import conf
from django.test import TestCase
-from django.utils._os import upath
class TestStartProjectSettings(TestCase):
def setUp(self):
# Ensure settings.py exists
project_dir = os.path.join(
- os.path.dirname(upath(conf.__file__)),
+ os.path.dirname(conf.__file__),
'project_template',
'project_name',
)
diff --git a/tests/proxy_model_inheritance/tests.py b/tests/proxy_model_inheritance/tests.py
index 9bf8f1c04c..9fb5f4e924 100644
--- a/tests/proxy_model_inheritance/tests.py
+++ b/tests/proxy_model_inheritance/tests.py
@@ -3,7 +3,6 @@ import os
from django.core.management import call_command
from django.test import TestCase, TransactionTestCase
from django.test.utils import extend_sys_path
-from django.utils._os import upath
from .models import (
ConcreteModel, ConcreteModelSubclass, ConcreteModelSubclassProxy,
@@ -20,7 +19,7 @@ class ProxyModelInheritanceTests(TransactionTestCase):
available_apps = []
def test_table_exists(self):
- with extend_sys_path(os.path.dirname(os.path.abspath(upath(__file__)))):
+ with extend_sys_path(os.path.dirname(os.path.abspath(__file__))):
with self.modify_settings(INSTALLED_APPS={'append': ['app1', 'app2']}):
call_command('migrate', verbosity=0, run_syncdb=True)
from app1.models import ProxyModel
diff --git a/tests/runtests.py b/tests/runtests.py
index 6e86bf7a93..57ba84d3db 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -17,7 +17,6 @@ from django.test import TestCase, TransactionTestCase
from django.test.runner import default_test_processes
from django.test.selenium import SeleniumTestCaseBase
from django.test.utils import get_runner
-from django.utils._os import upath
from django.utils.deprecation import (
RemovedInDjango21Warning, RemovedInDjango30Warning,
)
@@ -31,7 +30,7 @@ warnings.simplefilter("error", RuntimeWarning)
# Ignore known warnings in test dependencies.
warnings.filterwarnings("ignore", "'U' mode is deprecated", DeprecationWarning, module='docutils.io')
-RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
+RUNTESTS_DIR = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIR = os.path.join(RUNTESTS_DIR, 'templates')
@@ -276,7 +275,7 @@ def django_tests(verbosity, interactive, failfast, keepdb, reverse,
def get_subprocess_args(options):
subprocess_args = [
- sys.executable, upath(__file__), '--settings=%s' % options.settings
+ sys.executable, __file__, '--settings=%s' % options.settings
]
if options.failfast:
subprocess_args.append('--failfast')
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index 82c9bea493..d6d0392bcd 100644
--- a/tests/servers/tests.py
+++ b/tests/servers/tests.py
@@ -8,12 +8,11 @@ from urllib.error import HTTPError
from urllib.request import urlopen
from django.test import LiveServerTestCase, override_settings
-from django.utils._os import upath
from django.utils.http import urlencode
from .models import Person
-TEST_ROOT = os.path.dirname(upath(__file__))
+TEST_ROOT = os.path.dirname(__file__)
TEST_SETTINGS = {
'MEDIA_URL': '/media/',
'MEDIA_ROOT': os.path.join(TEST_ROOT, 'media'),
diff --git a/tests/sitemaps_tests/test_http.py b/tests/sitemaps_tests/test_http.py
index ec7d2be80f..a93d879164 100644
--- a/tests/sitemaps_tests/test_http.py
+++ b/tests/sitemaps_tests/test_http.py
@@ -8,7 +8,6 @@ from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import modify_settings, override_settings
-from django.utils._os import upath
from django.utils.formats import localize
from django.utils.translation import activate, deactivate
@@ -30,7 +29,7 @@ class HTTPSitemapTests(SitemapTestsBase):
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
+ 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')],
}])
def test_simple_sitemap_custom_index(self):
"A simple sitemap index can be rendered with a custom template"
@@ -65,7 +64,7 @@ class HTTPSitemapTests(SitemapTestsBase):
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')],
+ 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')],
}])
def test_simple_custom_sitemap(self):
"A simple sitemap can be rendered with a custom template"
diff --git a/tests/staticfiles_tests/settings.py b/tests/staticfiles_tests/settings.py
index c9bf851db7..0c944b8191 100644
--- a/tests/staticfiles_tests/settings.py
+++ b/tests/staticfiles_tests/settings.py
@@ -1,8 +1,6 @@
import os.path
-from django.utils._os import upath
-
-TEST_ROOT = os.path.dirname(upath(__file__))
+TEST_ROOT = os.path.dirname(__file__)
TEST_SETTINGS = {
'MEDIA_URL': '/media/',
diff --git a/tests/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py
index 717de5cf64..f45a95ba89 100644
--- a/tests/staticfiles_tests/test_liveserver.py
+++ b/tests/staticfiles_tests/test_liveserver.py
@@ -10,9 +10,8 @@ from urllib.request import urlopen
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.core.exceptions import ImproperlyConfigured
from django.test import modify_settings, override_settings
-from django.utils._os import upath
-TEST_ROOT = os.path.dirname(upath(__file__))
+TEST_ROOT = os.path.dirname(__file__)
TEST_SETTINGS = {
'MEDIA_URL': '/media/',
'STATIC_URL': '/static/',
diff --git a/tests/template_tests/syntax_tests/i18n/base.py b/tests/template_tests/syntax_tests/i18n/base.py
index 690e5d3933..61d2bbdb1c 100644
--- a/tests/template_tests/syntax_tests/i18n/base.py
+++ b/tests/template_tests/syntax_tests/i18n/base.py
@@ -2,10 +2,9 @@ import os
from django.conf import settings
from django.test import SimpleTestCase
-from django.utils._os import upath
from django.utils.translation import activate, get_language
-here = os.path.dirname(os.path.dirname(os.path.abspath(upath(__file__))))
+here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
pdir = os.path.split(os.path.split(os.path.abspath(here))[0])[0]
extended_locale_paths = settings.LOCALE_PATHS + [
os.path.join(pdir, 'i18n', 'other', 'locale'),
diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py
index 8ee66a6523..e2a9305b5e 100644
--- a/tests/template_tests/utils.py
+++ b/tests/template_tests/utils.py
@@ -3,10 +3,9 @@ import os
from django.template.engine import Engine
from django.test.utils import override_settings
-from django.utils._os import upath
from django.utils.safestring import mark_safe
-ROOT = os.path.dirname(os.path.abspath(upath(__file__)))
+ROOT = os.path.dirname(os.path.abspath(__file__))
TEMPLATE_DIR = os.path.join(ROOT, 'templates')
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index 16b344e0ae..4589ac33bd 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -17,7 +17,6 @@ from django.test import (
from django.test.client import RedirectCycleError, RequestFactory, encode_file
from django.test.utils import ContextList, str_prefix
from django.urls import NoReverseMatch, reverse
-from django.utils._os import upath
from django.utils.translation import ugettext_lazy
from .models import CustomUser
@@ -874,7 +873,7 @@ class TemplateExceptionTests(SimpleTestCase):
@override_settings(TEMPLATES=[{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'bad_templates')],
+ 'DIRS': [os.path.join(os.path.dirname(__file__), 'bad_templates')],
}])
def test_bad_404_template(self):
"Errors found when rendering 404 error templates are re-raised"
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index b1c35d1f80..ea094bbd55 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1,3 +1,4 @@
+import os
import sys
import unittest
from io import StringIO
@@ -19,7 +20,6 @@ from django.test.utils import (
setup_test_environment,
)
from django.urls import NoReverseMatch, reverse
-from django.utils._os import abspathu
from .models import Car, Person, PossessedCar
from .views import empty_response
@@ -968,7 +968,7 @@ class OverrideSettingsTests(SimpleTestCase):
django.contrib.staticfiles.storage.staticfiles_storage.
"""
with self.settings(STATIC_ROOT='/tmp/test'):
- self.assertEqual(staticfiles_storage.location, abspathu('/tmp/test'))
+ self.assertEqual(staticfiles_storage.location, os.path.abspath('/tmp/test'))
def test_override_staticfiles_storage(self):
"""
diff --git a/tests/urlpatterns_reverse/test_localeregexprovider.py b/tests/urlpatterns_reverse/test_localeregexprovider.py
index 53dc744c77..f05c446eb9 100644
--- a/tests/urlpatterns_reverse/test_localeregexprovider.py
+++ b/tests/urlpatterns_reverse/test_localeregexprovider.py
@@ -5,9 +5,8 @@ from django.test import SimpleTestCase, mock, override_settings
from django.urls import LocaleRegexProvider
from django.urls.resolvers import LocaleRegexDescriptor
from django.utils import translation
-from django.utils._os import upath
-here = os.path.dirname(upath(os.path.abspath(__file__)))
+here = os.path.dirname(os.path.abspath(__file__))
@override_settings(LOCALE_PATHS=[os.path.join(here, 'translations', 'locale')])
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index cfc4f5fb2e..a18d49868b 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -11,7 +11,6 @@ from django.db import connection
from django.test import SimpleTestCase, mock, override_settings
from django.test.utils import captured_stderr, extend_sys_path
from django.utils import translation
-from django.utils._os import upath
from .management.commands import dance
@@ -92,7 +91,7 @@ class CommandTests(SimpleTestCase):
"""
Management commands can also be loaded from Python eggs.
"""
- egg_dir = '%s/eggs' % os.path.dirname(upath(__file__))
+ egg_dir = '%s/eggs' % os.path.dirname(__file__)
egg_name = '%s/basic.egg' % egg_dir
with extend_sys_path(egg_name):
with self.settings(INSTALLED_APPS=['commandegg']):
diff --git a/tests/utils_tests/test_archive.py b/tests/utils_tests/test_archive.py
index f50e18d75c..d58d211ae5 100644
--- a/tests/utils_tests/test_archive.py
+++ b/tests/utils_tests/test_archive.py
@@ -5,10 +5,9 @@ import sys
import tempfile
import unittest
-from django.utils._os import upath
from django.utils.archive import Archive, extract
-TEST_DIR = os.path.join(os.path.dirname(upath(__file__)), 'archives')
+TEST_DIR = os.path.join(os.path.dirname(__file__), 'archives')
class ArchiveTester:
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index 4036df8dd8..6925da1834 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -11,7 +11,6 @@ from django.contrib import admin
from django.test import SimpleTestCase, mock, override_settings
from django.test.utils import extend_sys_path
from django.utils import autoreload
-from django.utils._os import npath
from django.utils.translation import trans_real
LOCALE_PATH = os.path.join(os.path.dirname(__file__), 'locale')
@@ -26,23 +25,23 @@ class TestFilenameGenerator(SimpleTestCase):
def assertFileFound(self, filename):
self.clear_autoreload_caches()
# Test uncached access
- self.assertIn(npath(filename), autoreload.gen_filenames())
+ self.assertIn(filename, autoreload.gen_filenames())
# Test cached access
- self.assertIn(npath(filename), autoreload.gen_filenames())
+ self.assertIn(filename, autoreload.gen_filenames())
def assertFileNotFound(self, filename):
self.clear_autoreload_caches()
# Test uncached access
- self.assertNotIn(npath(filename), autoreload.gen_filenames())
+ self.assertNotIn(filename, autoreload.gen_filenames())
# Test cached access
- self.assertNotIn(npath(filename), autoreload.gen_filenames())
+ self.assertNotIn(filename, autoreload.gen_filenames())
def assertFileFoundOnlyNew(self, filename):
self.clear_autoreload_caches()
# Test uncached access
- self.assertIn(npath(filename), autoreload.gen_filenames(only_new=True))
+ self.assertIn(filename, autoreload.gen_filenames(only_new=True))
# Test cached access
- self.assertNotIn(npath(filename), autoreload.gen_filenames(only_new=True))
+ self.assertNotIn(filename, autoreload.gen_filenames(only_new=True))
def test_django_locales(self):
"""
@@ -122,7 +121,7 @@ class TestFilenameGenerator(SimpleTestCase):
with extend_sys_path(dirname):
import_module('test_only_new_module')
filenames = set(autoreload.gen_filenames(only_new=True))
- self.assertEqual(filenames, {npath(filename)})
+ self.assertEqual(filenames, {filename})
def test_deleted_removed(self):
"""
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index 5ffccdae83..c2a64699cb 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -3,7 +3,6 @@ from datetime import datetime
from django.test import SimpleTestCase
from django.utils import html, safestring
-from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.functional import lazystr
@@ -98,7 +97,7 @@ class TestUtilsHtml(SimpleTestCase):
# Test with more lengthy content (also catching performance regressions)
for filename in ('strip_tags1.html', 'strip_tags2.txt'):
- path = os.path.join(os.path.dirname(upath(__file__)), 'files', filename)
+ path = os.path.join(os.path.dirname(__file__), 'files', filename)
with open(path, 'r') as fp:
content = force_text(fp.read())
start = datetime.now()
diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py
index 8e6806e8d5..ad1135aa19 100644
--- a/tests/utils_tests/test_module_loading.py
+++ b/tests/utils_tests/test_module_loading.py
@@ -7,7 +7,6 @@ from zipimport import zipimporter
from django.test import SimpleTestCase, TestCase, modify_settings
from django.test.utils import extend_sys_path
-from django.utils._os import upath
from django.utils.module_loading import (
autodiscover_modules, import_string, module_has_submodule,
)
@@ -58,7 +57,7 @@ class DefaultLoader(unittest.TestCase):
class EggLoader(unittest.TestCase):
def setUp(self):
- self.egg_dir = '%s/eggs' % os.path.dirname(upath(__file__))
+ self.egg_dir = '%s/eggs' % os.path.dirname(__file__)
def tearDown(self):
sys.path_importer_cache.clear()
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 2f26efcaa5..124c2b1c68 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -17,7 +17,6 @@ from django.core.validators import (
)
from django.test import SimpleTestCase
from django.test.utils import str_prefix
-from django.utils._os import upath
try:
from PIL import Image # noqa
@@ -263,7 +262,7 @@ TEST_DATA = [
def create_path(filename):
- return os.path.abspath(os.path.join(os.path.dirname(upath(__file__)), filename))
+ return os.path.abspath(os.path.join(os.path.dirname(__file__), filename))
# Add valid and invalid URL tests.
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index d330b60ff7..f9c49ad3bb 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -8,7 +8,6 @@ from django.test import (
)
from django.test.selenium import SeleniumTestCase
from django.urls import reverse
-from django.utils._os import upath
from django.utils.translation import (
LANGUAGE_SESSION_KEY, get_language, override,
)
@@ -373,7 +372,7 @@ class JsI18NTestsMultiPackage(SimpleTestCase):
def test_i18n_with_locale_paths(self):
extended_locale_paths = settings.LOCALE_PATHS + [
path.join(
- path.dirname(path.dirname(path.abspath(upath(__file__)))),
+ path.dirname(path.dirname(path.abspath(__file__))),
'app3',
'locale',
),
diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py
index c536ea78ed..c046336b7f 100644
--- a/tests/view_tests/urls.py
+++ b/tests/view_tests/urls.py
@@ -3,13 +3,12 @@ from os import path
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
-from django.utils._os import upath
from django.utils.translation import ugettext_lazy as _
from django.views import defaults, i18n, static
from . import views
-base_dir = path.dirname(path.abspath(upath(__file__)))
+base_dir = path.dirname(path.abspath(__file__))
media_dir = path.join(base_dir, 'media')
locale_dir = path.join(base_dir, 'locale')