Passed strict=True to Path.resolve() to enforce that the path must exist.

This commit is contained in:
Jon Dufresne 2019-11-01 20:18:48 -07:00 committed by Carlton Gibson
parent b991eefd3a
commit edeec1247e
2 changed files with 5 additions and 5 deletions

View File

@ -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:

View File

@ -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()