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

Commit9151c38

Browse files
committed
Test "installing" another git and refreshing
This is trickier to test than the other cases, but important enoughthat I think it deserves its own test.
1 parent626a550 commit9151c38

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

‎test/test_git.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
importmock# To be able to examine call_args.kwargs on a mock.
2525

2626
importddt
27+
importpytest
2728

2829
fromgitimportGit,refresh,GitCommandError,GitCommandNotFound,Repo,cmd
2930
fromgit.utilimportcwd,finalize_process
@@ -611,6 +612,30 @@ def test_successful_refresh_with_same_env_invalidates_cached_version_info(self):
611612
refresh()# The fake git at path1 has a different version now.
612613
self.assertEqual(new_git.version_info, (22,222,2))
613614

615+
@pytest.mark.xfail(
616+
os.name=="nt",
617+
reason="""Name "git" won't find .bat/.cmd (need shim, custom name, or shell)""",
618+
raises=GitCommandNotFound,
619+
)
620+
deftest_successful_refresh_in_default_scenario_invalidates_cached_version(self):
621+
"""Refreshing updates version after a filesystem change adds a git command."""
622+
withcontextlib.ExitStack()asstack:
623+
stack.enter_context(_rollback_refresh())
624+
path1=Path(stack.enter_context(_fake_git(11,111,1)))
625+
path2=Path(stack.enter_context(_fake_git(22,222,2)))
626+
sep=os.pathsep
627+
new_path_var=f"{path1.parent}{sep}{path2.parent}{sep}{os.environ['PATH']}"
628+
stack.enter_context(mock.patch.dict(os.environ, {"PATH":new_path_var}))
629+
stack.enter_context(_patch_out_env("GIT_PYTHON_GIT_EXECUTABLE"))
630+
new_git=Git()
631+
path2.rename(path2.with_stem("git"))
632+
refresh()
633+
self.assertEqual(new_git.version_info, (22,222,2),'before "downgrade"')
634+
path1.rename(path1.with_stem("git"))
635+
self.assertEqual(new_git.version_info, (22,222,2),"stale version")
636+
refresh()
637+
self.assertEqual(new_git.version_info, (11,111,1),"fresh version")
638+
614639
deftest_options_are_passed_to_git(self):
615640
# This works because any command after git --version is ignored.
616641
git_version=self.git(version=True).NoOp()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp