Skip to content

Commit 32a5b94

Browse files
committed
test(git): Modernize a test a bit
1 parent 9c28c98 commit 32a5b94

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

tests/sync/test_git.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,32 +186,31 @@ def test_repo_update_stash_cases(
186186
)
187187
git_repo.obtain() # clone initial repo
188188

189-
def make_file(filename: str) -> pathlib.Path:
190-
some_file = git_repo.dir.joinpath(filename)
191-
with open(some_file, "w") as file:
192-
file.write("some content: " + str(random.random()))
193-
194-
return some_file
195-
196189
# Make an initial commit so we can reset
197-
some_file = make_file("initial_file")
198-
git_repo.run(["add", some_file])
190+
initial_file = git_repo.dir / "initial_file"
191+
initial_file.write_text(f"some content: {random.random()}", encoding="utf-8")
192+
git_repo.run(["add", str(initial_file)])
199193
git_repo.run(["commit", "-m", "a commit"])
200194
git_repo.run(["push"])
201195

202196
if has_remote_changes:
203-
some_file = make_file("some_file")
197+
some_file = git_repo.dir / "some_file"
198+
some_file.write_text(f"some content: {random.random()}", encoding="utf-8")
204199
git_repo.run(["add", some_file])
205200
git_repo.run(["commit", "-m", "a commit"])
206201
git_repo.run(["push"])
207202
git_repo.run(["reset", "--hard", "HEAD^"])
208203

209204
if has_untracked_files:
210-
make_file("some_file")
205+
some_file = git_repo.dir / "some_file"
206+
some_file.write_text(f"some content: {random.random()}", encoding="utf-8")
211207

212208
if needs_stash:
213-
some_file = make_file("some_stashed_file")
214-
git_repo.run(["add", some_file])
209+
some_stashed_file = git_repo.dir / "some_stashed_file"
210+
some_stashed_file.write_text(
211+
f"some content: {random.random()}", encoding="utf-8"
212+
)
213+
git_repo.run(["add", some_stashed_file])
215214

216215
cmd_mock = mocker.spy(git_repo.cmd, "symbolic_ref")
217216
git_repo.update_repo()

0 commit comments

Comments
 (0)