summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-11-01 20:18:48 -0700
committerCarlton Gibson <carlton.gibson@noumenal.es>2019-11-05 14:22:20 +0100
commitedeec1247e52de6fc32cee93e96d4ce36003ea4b (patch)
treed16e5f69dca4ddf5b0b81c4c696c786a43cd0e99
parentb991eefd3a9fa4da4eb46fddcb36cf1e8b5862e9 (diff)
Passed strict=True to Path.resolve() to enforce that the path must exist.
-rw-r--r--django/contrib/auth/password_validation.py2
-rw-r--r--tests/utils_tests/test_autoreload.py8
2 files changed, 5 insertions, 5 deletions
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py
index 845f4d86d5..61a482fdad 100644
--- a/django/contrib/auth/password_validation.py
+++ b/django/contrib/auth/password_validation.py
@@ -167,7 +167,7 @@ class CommonPasswordValidator:
https://gist.github.com/roycewilliams/281ce539915a947a23db17137d91aeb7
The password list must be lowercased to match the comparison in validate().
"""
- DEFAULT_PASSWORD_LIST_PATH = Path(__file__).resolve().parent / 'common-passwords.txt.gz'
+ DEFAULT_PASSWORD_LIST_PATH = Path(__file__).resolve(strict=True).parent / 'common-passwords.txt.gz'
def __init__(self, password_list_path=DEFAULT_PASSWORD_LIST_PATH):
try:
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index fe89f897c7..09656b8599 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -35,7 +35,7 @@ class TestIterModulesAndFiles(SimpleTestCase):
def assertFileFound(self, filename):
# Some temp directories are symlinks. Python resolves these fully while
# importing.
- resolved_filename = filename.resolve()
+ resolved_filename = filename.resolve(strict=True)
self.clear_autoreload_caches()
# Test uncached access
self.assertIn(resolved_filename, list(autoreload.iter_all_python_module_files()))
@@ -44,7 +44,7 @@ class TestIterModulesAndFiles(SimpleTestCase):
self.assertEqual(autoreload.iter_modules_and_files.cache_info().hits, 1)
def assertFileNotFound(self, filename):
- resolved_filename = filename.resolve()
+ resolved_filename = filename.resolve(strict=True)
self.clear_autoreload_caches()
# Test uncached access
self.assertNotIn(resolved_filename, list(autoreload.iter_all_python_module_files()))
@@ -168,7 +168,7 @@ class TestCommonRoots(SimpleTestCase):
class TestSysPathDirectories(SimpleTestCase):
def setUp(self):
self._directory = tempfile.TemporaryDirectory()
- self.directory = Path(self._directory.name).resolve().absolute()
+ self.directory = Path(self._directory.name).resolve(strict=True).absolute()
self.file = self.directory / 'test'
self.file.touch()
@@ -381,7 +381,7 @@ class ReloaderTests(SimpleTestCase):
def setUp(self):
self._tempdir = tempfile.TemporaryDirectory()
- self.tempdir = Path(self._tempdir.name).resolve().absolute()
+ self.tempdir = Path(self._tempdir.name).resolve(strict=True).absolute()
self.existing_file = self.ensure_file(self.tempdir / 'test.py')
self.nonexistent_file = (self.tempdir / 'does_not_exist.py').absolute()
self.reloader = self.RELOADER_CLS()