Skip to content

Commit f64e932

Browse files
TheSven73Secrus
authored andcommitted
MockDulwichRepo: mimick git behaviour more closely
When git clones a repo in a base directory, it will place the clone in a subdirectory of the base. That subdirectory is named after the repo url name, which is the "testing" right before the .git in https://github.com/test/testing.git This behaviour may introduce race conditions to Poetry. Let the mock repo mimic it, so that the (absence of) race conditions can be verified.
1 parent cf6dddd commit f64e932

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tests/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def mock_clone(
113113
if not source_root:
114114
source_root = Path(Config.create().get("cache-dir")) / "src"
115115

116-
dest = source_root / path
116+
assert parsed.name is not None
117+
dest = source_root / parsed.name
117118
dest.mkdir(parents=True, exist_ok=True)
118119

119120
copy_path(folder, dest)

tests/installation/test_executor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ def test_executor_should_append_subdirectory_for_git(
10911091
executor.execute([Install(package)])
10921092

10931093
archive_arg = spy.call_args[0][0]
1094-
assert archive_arg == tmp_venv.path / "src/demo/subdirectories/two"
1094+
assert archive_arg == tmp_venv.path / "src/subdirectories/two"
10951095

10961096

10971097
def test_executor_should_install_multiple_packages_from_same_git_repository(
@@ -1131,10 +1131,10 @@ def test_executor_should_install_multiple_packages_from_same_git_repository(
11311131
executor.execute([Install(package_a), Install(package_b)])
11321132

11331133
archive_arg = spy.call_args_list[0][0][0]
1134-
assert archive_arg == tmp_venv.path / "src/demo/subdirectories/package_a"
1134+
assert archive_arg == tmp_venv.path / "src/subdirectories/package_a"
11351135

11361136
archive_arg = spy.call_args_list[1][0][0]
1137-
assert archive_arg == tmp_venv.path / "src/demo/subdirectories/package_b"
1137+
assert archive_arg == tmp_venv.path / "src/subdirectories/package_b"
11381138

11391139

11401140
@pytest.mark.xfail

0 commit comments

Comments
 (0)