From edeec1247e52de6fc32cee93e96d4ce36003ea4b Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Fri, 1 Nov 2019 20:18:48 -0700 Subject: [PATCH] Passed strict=True to Path.resolve() to enforce that the path must exist. --- django/contrib/auth/password_validation.py | 2 +- tests/utils_tests/test_autoreload.py | 8 ++++---- 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()