Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7da9c3b

Browse files
committed
Refactor "not from cwd" test for readability
By using pathlib.Path instead of os.path functions.
1 parent06bd2c7 commit7da9c3b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎test/test_git.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
importlogging
1010
importos
1111
importos.pathasosp
12+
frompathlibimportPath
1213
importre
1314
importshutil
1415
importsubprocess
@@ -150,14 +151,13 @@ def test_it_executes_git_not_from_cwd(self, rw_dir, case):
150151
ifos.name=="nt":
151152
# Copy an actual binary executable that is not git. (On Windows, running
152153
# "hostname" only displays the hostname, it never tries to change it.)
153-
other_exe_path=os.path.join(os.environ["SystemRoot"],"system32","hostname.exe")
154-
impostor_path=os.path.join(rw_dir,"git.exe")
154+
other_exe_path=Path(os.environ["SystemRoot"],"system32","hostname.exe")
155+
impostor_path=Path(rw_dir,"git.exe")
155156
shutil.copy(other_exe_path,impostor_path)
156157
else:
157158
# Create a shell script that doesn't do anything.
158-
impostor_path=os.path.join(rw_dir,"git")
159-
withopen(impostor_path,mode="w",encoding="utf-8")asfile:
160-
print("#!/bin/sh",file=file)
159+
impostor_path=Path(rw_dir,"git")
160+
impostor_path.write_text("#!/bin/sh\n",encoding="utf-8")
161161
os.chmod(impostor_path,0o755)
162162

163163
withcwd(rw_dir)ifchdir_to_repoelsecontextlib.nullcontext():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp