mirror of https://github.com/django/django.git
Passed strict=True to Path.resolve() to enforce that the path must exist.
This commit is contained in:
parent
b991eefd3a
commit
edeec1247e
|
@ -167,7 +167,7 @@ class CommonPasswordValidator:
|
||||||
https://gist.github.com/roycewilliams/281ce539915a947a23db17137d91aeb7
|
https://gist.github.com/roycewilliams/281ce539915a947a23db17137d91aeb7
|
||||||
The password list must be lowercased to match the comparison in validate().
|
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):
|
def __init__(self, password_list_path=DEFAULT_PASSWORD_LIST_PATH):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -35,7 +35,7 @@ class TestIterModulesAndFiles(SimpleTestCase):
|
||||||
def assertFileFound(self, filename):
|
def assertFileFound(self, filename):
|
||||||
# Some temp directories are symlinks. Python resolves these fully while
|
# Some temp directories are symlinks. Python resolves these fully while
|
||||||
# importing.
|
# importing.
|
||||||
resolved_filename = filename.resolve()
|
resolved_filename = filename.resolve(strict=True)
|
||||||
self.clear_autoreload_caches()
|
self.clear_autoreload_caches()
|
||||||
# Test uncached access
|
# Test uncached access
|
||||||
self.assertIn(resolved_filename, list(autoreload.iter_all_python_module_files()))
|
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)
|
self.assertEqual(autoreload.iter_modules_and_files.cache_info().hits, 1)
|
||||||
|
|
||||||
def assertFileNotFound(self, filename):
|
def assertFileNotFound(self, filename):
|
||||||
resolved_filename = filename.resolve()
|
resolved_filename = filename.resolve(strict=True)
|
||||||
self.clear_autoreload_caches()
|
self.clear_autoreload_caches()
|
||||||
# Test uncached access
|
# Test uncached access
|
||||||
self.assertNotIn(resolved_filename, list(autoreload.iter_all_python_module_files()))
|
self.assertNotIn(resolved_filename, list(autoreload.iter_all_python_module_files()))
|
||||||
|
@ -168,7 +168,7 @@ class TestCommonRoots(SimpleTestCase):
|
||||||
class TestSysPathDirectories(SimpleTestCase):
|
class TestSysPathDirectories(SimpleTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._directory = tempfile.TemporaryDirectory()
|
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 = self.directory / 'test'
|
||||||
self.file.touch()
|
self.file.touch()
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ class ReloaderTests(SimpleTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._tempdir = tempfile.TemporaryDirectory()
|
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.existing_file = self.ensure_file(self.tempdir / 'test.py')
|
||||||
self.nonexistent_file = (self.tempdir / 'does_not_exist.py').absolute()
|
self.nonexistent_file = (self.tempdir / 'does_not_exist.py').absolute()
|
||||||
self.reloader = self.RELOADER_CLS()
|
self.reloader = self.RELOADER_CLS()
|
||||||
|
|
Loading…
Reference in New Issue