Skip to content

Commit 8875ce7

Browse files
committed
fix tests
1 parent 9527ee9 commit 8875ce7

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

scripts/src/scverse_template_scripts/cruft_prs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
log = getLogger(__name__)
3232
log_dir = Path("./log")
33-
log_dir.mkdir()
33+
log_dir.mkdir(exist_ok=True)
3434

3535
PR_BODY_TEMPLATE = """\
3636
`cookiecutter-scverse` released [{release.tag_name}]({release.html_url}).
@@ -161,7 +161,7 @@ def run_cruft(cwd: Path, git_tag: str, log_name: str) -> CompletedProcess:
161161
# Due to exponential backoff, we’ll maximally wait 2⁹ sec, or 8.5 min
162162

163163

164-
def cruft_update(con: GitHubConnection, release: GHRelease, repo: GHRepo, path: Path, pr: PR) -> bool:
164+
def cruft_update(con: GitHubConnection, tag_name: str, repo: GHRepo, path: Path, pr: PR) -> bool:
165165
clone = retry_with_backoff(
166166
lambda: Repo.clone_from(con.auth(repo.clone_url), path),
167167
retries=n_retries,
@@ -170,7 +170,7 @@ def cruft_update(con: GitHubConnection, release: GHRelease, repo: GHRepo, path:
170170
branch = clone.create_head(pr.branch, clone.active_branch)
171171
branch.checkout()
172172

173-
run_cruft(path, release.tag_name, pr.branch)
173+
run_cruft(path, tag_name, pr.branch)
174174

175175
if not clone.is_dirty():
176176
return False
@@ -209,7 +209,7 @@ def make_pr(con: GitHubConnection, release: GHRelease, repo_url: str) -> None:
209209
origin = con.gh.get_repo(repo_url.removeprefix("https://github.com/"))
210210
repo = get_fork(con, origin)
211211
with TemporaryDirectory() as td:
212-
updated = cruft_update(con, release, repo, Path(td), pr)
212+
updated = cruft_update(con, release.tag_name, repo, Path(td), pr)
213213
if updated:
214214
if old_pr := next((p for p in origin.get_pulls("open") if pr.matches(p)), None):
215215
old_pr.edit(state="closed")

scripts/tests/test_cruft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def test_cruft_update(con, repo, tmp_path, pr, git_repo: GitRepo, monkeypatch: p
5151
old_active_branch_name = git_repo.api.active_branch.name
5252
monkeypatch.setattr(
5353
"scverse_template_scripts.cruft_prs.run_cruft",
54-
lambda p: (p / "b").write_text("b modified"),
54+
lambda p, _, __: (p / "b").write_text("b modified"),
5555
)
56-
changed = cruft_update(con, repo, tmp_path, pr)
56+
changed = cruft_update(con, "main", repo, tmp_path, pr)
5757
assert changed # TODO: add test for short circuit
5858
main_branch = git_repo.api.active_branch
5959
assert main_branch.name == old_active_branch_name, "Shouldn’t change active branch"

0 commit comments

Comments
 (0)