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

Commitb3fc30e

Browse files
committed
Re-refresh to restore state after refresh tests
For#1811. This is the simple way to do it. This relies ongit.refresh working when called when no arguments, so if that everbreaks, then it may be difficult or inefficient to investigate. Butthis is simpler than any alternatives that are equally or morerobust.This is already better than the previous incomplete way that onlyrestored Git.GIT_PYTHON_GIT_EXECUTABLE (and nothing in FetchInfo).Furthermore, because the tests already depend to a large extent ongit.refreh working when called with no arguments, as otherwise theinitial refresh may not have set Git.GIT_PYTHON_GIT_EXECUTABLEusably, it might not be worthwhile to explore other approaches.
1 parent5ad7cb2 commitb3fc30e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

‎test/test_git.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ def _patch_out_env(name):
4545

4646

4747
@contextlib.contextmanager
48-
def_restore_git_executable():
48+
def_rollback_refresh():
4949
old_git_executable=Git.GIT_PYTHON_GIT_EXECUTABLE
5050
try:
51-
yieldold_git_executable# Let test code run that mayrebind the attribute.
51+
yieldold_git_executable# Let test code run that maymutate class state.
5252
finally:
53-
Git.GIT_PYTHON_GIT_EXECUTABLE=old_git_executable
53+
refresh()
5454

5555

5656
@ddt.ddt
@@ -319,7 +319,7 @@ def test_refresh_bad_absolute_git_path(self):
319319
absolute_path=str(Path("yada").absolute())
320320
expected_pattern=rf"\n[ \t]*cmdline:{re.escape(absolute_path)}\Z"
321321

322-
with_restore_git_executable()asold_git_executable:
322+
with_rollback_refresh()asold_git_executable:
323323
withself.assertRaisesRegex(GitCommandNotFound,expected_pattern):
324324
refresh(absolute_path)
325325
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE,old_git_executable)
@@ -328,15 +328,15 @@ def test_refresh_bad_relative_git_path(self):
328328
absolute_path=str(Path("yada").absolute())
329329
expected_pattern=rf"\n[ \t]*cmdline:{re.escape(absolute_path)}\Z"
330330

331-
with_restore_git_executable()asold_git_executable:
331+
with_rollback_refresh()asold_git_executable:
332332
withself.assertRaisesRegex(GitCommandNotFound,expected_pattern):
333333
refresh("yada")
334334
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE,old_git_executable)
335335

336336
deftest_refresh_good_absolute_git_path(self):
337337
absolute_path=shutil.which("git")
338338

339-
with_restore_git_executable():
339+
with_rollback_refresh():
340340
refresh(absolute_path)
341341
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE,absolute_path)
342342

@@ -345,7 +345,7 @@ def test_refresh_good_relative_git_path(self):
345345
dirname,basename=osp.split(absolute_path)
346346

347347
withcwd(dirname):
348-
with_restore_git_executable():
348+
with_rollback_refresh():
349349
refresh(basename)
350350
self.assertEqual(self.git.GIT_PYTHON_GIT_EXECUTABLE,absolute_path)
351351

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp