parent
bf1195612c
commit
c9d2635b55
@ -474,20 +474,8 @@ def test_false_positive_symlink_output_issue_3384(self) -> None:
|
|||||||
# running from CLI, but fails when running the tests because cwd is different
|
# running from CLI, but fails when running the tests because cwd is different
|
||||||
project_root = Path(THIS_DIR / "data" / "nested_gitignore_tests")
|
project_root = Path(THIS_DIR / "data" / "nested_gitignore_tests")
|
||||||
working_directory = project_root / "root"
|
working_directory = project_root / "root"
|
||||||
target_abspath = working_directory / "child"
|
|
||||||
target_contents = list(target_abspath.iterdir())
|
|
||||||
|
|
||||||
def mock_n_calls(responses: List[bool]) -> Callable[[], bool]:
|
with change_directory(working_directory):
|
||||||
def _mocked_calls() -> bool:
|
|
||||||
if responses:
|
|
||||||
return responses.pop(0)
|
|
||||||
return False
|
|
||||||
|
|
||||||
return _mocked_calls
|
|
||||||
|
|
||||||
with patch("pathlib.Path.iterdir", return_value=target_contents), patch(
|
|
||||||
"pathlib.Path.resolve", return_value=target_abspath
|
|
||||||
), patch("pathlib.Path.is_dir", side_effect=mock_n_calls([True])):
|
|
||||||
# Note that the root folder (project_root) isn't the folder
|
# Note that the root folder (project_root) isn't the folder
|
||||||
# named "root" (aka working_directory)
|
# named "root" (aka working_directory)
|
||||||
report = MagicMock(verbose=True)
|
report = MagicMock(verbose=True)
|
||||||
@ -2692,11 +2680,19 @@ def test_get_sources_symlink_and_force_exclude(self) -> None:
|
|||||||
def test_get_sources_with_stdin_symlink_outside_root(
|
def test_get_sources_with_stdin_symlink_outside_root(
|
||||||
self,
|
self,
|
||||||
) -> None:
|
) -> None:
|
||||||
path = THIS_DIR / "data" / "include_exclude_tests"
|
with TemporaryDirectory() as tempdir:
|
||||||
stdin_filename = str(path / "b/exclude/a.py")
|
tmp = Path(tempdir).resolve()
|
||||||
outside_root_symlink = Path("/target_directory/a.py")
|
|
||||||
root = Path("target_dir/").resolve().absolute()
|
root = tmp / "root"
|
||||||
with patch("pathlib.Path.resolve", return_value=outside_root_symlink):
|
root.mkdir()
|
||||||
|
(root / "pyproject.toml").write_text("[tool.black]", encoding="utf-8")
|
||||||
|
|
||||||
|
target = tmp / "outside_root" / "a.py"
|
||||||
|
target.parent.mkdir()
|
||||||
|
target.write_text("print('hello')", encoding="utf-8")
|
||||||
|
(root / "a.py").symlink_to(target)
|
||||||
|
|
||||||
|
stdin_filename = str(root / "a.py")
|
||||||
assert_collected_sources(
|
assert_collected_sources(
|
||||||
root=root,
|
root=root,
|
||||||
src=["-"],
|
src=["-"],
|
||||||
|
Loading…
Reference in New Issue
Block a user