diff options
author | say <say@yandex-team.ru> | 2022-05-17 00:30:24 +0300 |
---|---|---|
committer | say <say@yandex-team.ru> | 2022-05-17 00:30:24 +0300 |
commit | 3fddaa3192396d921374ef959a73169c47d34af5 (patch) | |
tree | ea125fa2430421c42a018703a70f5ce94d98e866 /library/python/runtime_py3/test | |
parent | 45e5e9ae890daf63ba9a7a9550c1d64ac7e4734d (diff) | |
download | ydb-3fddaa3192396d921374ef959a73169c47d34af5.tar.gz |
YMAKE-148: Don't follow symlinks
ref:b200b70556036c6a735ab81b1414c4b334ba5958
Diffstat (limited to 'library/python/runtime_py3/test')
-rw-r--r-- | library/python/runtime_py3/test/test_arcadia_source_finder.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/library/python/runtime_py3/test/test_arcadia_source_finder.py b/library/python/runtime_py3/test/test_arcadia_source_finder.py index c01435f7df..09ade19043 100644 --- a/library/python/runtime_py3/test/test_arcadia_source_finder.py +++ b/library/python/runtime_py3/test/test_arcadia_source_finder.py @@ -1,5 +1,7 @@ +import stat import unittest import yaml +from collections import namedtuple from unittest.mock import patch from parameterized import parameterized @@ -17,9 +19,9 @@ class ImporterMocks(object): self._patchers = [ patch('__res.iter_keys', wraps=self._iter_keys), patch('__res.__resource.find', wraps=self._resource_find), - patch('__res._path_isdir', wraps=self._path_isdir), patch('__res._path_isfile', wraps=self._path_isfile), patch('__res._os.listdir', wraps=self._os_listdir), + patch('__res._os.lstat', wraps=self._os_lstat), ] for patcher in self._patchers: patcher.start() @@ -51,9 +53,10 @@ class ImporterMocks(object): f = self._lookup_mock_fs(filename) return isinstance(f, str) - def _path_isdir(self, filename): + def _os_lstat(self, filename): f = self._lookup_mock_fs(filename) - return isinstance(f, dict) + mode = stat.S_IFDIR if isinstance(f, dict) else stat.S_IFREG + return namedtuple('fake_stat_type', 'st_mode')(st_mode=mode) def _os_listdir(self, dirname): f = self._lookup_mock_fs(dirname) |