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

Commitc50416f

Browse files
committed
Example of deferred command
1 parentf1060be commitc50416f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎tests/cmd/test_git.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
importpytest
55

6+
fromlibvcs._internal.subprocessimportSubprocessCommand
67
fromlibvcs.cmdimportgit
78

89

@@ -11,3 +12,20 @@ def test_run(dir_type: Callable, tmp_path: pathlib.Path):
1112
repo=git.Git(dir=dir_type(tmp_path))
1213

1314
assertrepo.dir==tmp_path
15+
16+
17+
@pytest.mark.parametrize("dir_type", [str,pathlib.Path])
18+
deftest_run_deferred(dir_type:Callable,tmp_path:pathlib.Path):
19+
classGitDeferred(git.Git):
20+
defrun(self,args,**kwargs):
21+
returnSubprocessCommand(["git",*args],**kwargs)
22+
23+
g=GitDeferred(dir=dir_type(tmp_path))
24+
cmd=g.run(["help"])
25+
26+
assertg.dir==tmp_path
27+
assertcmd.args== ["git","help"]
28+
29+
assertcmd.run(capture_output=True,text=True).stdout.startswith(
30+
"usage: git [--version] [--help] [-C <path>]"
31+
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp