-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest_git.py
More file actions
31 lines (21 loc) · 870 Bytes
/
test_git.py
File metadata and controls
31 lines (21 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pathlib
from typing import Callable
import pytest
from libvcs._internal.subprocess import SubprocessCommand
from libvcs.cmd import git
@pytest.mark.parametrize("dir_type", [str, pathlib.Path])
def test_run(dir_type: Callable, tmp_path: pathlib.Path):
repo = git.Git(dir=dir_type(tmp_path))
assert repo.dir == tmp_path
@pytest.mark.parametrize("dir_type", [str, pathlib.Path])
def test_run_deferred(dir_type: Callable, tmp_path: pathlib.Path):
class GitDeferred(git.Git):
def run(self, args, **kwargs):
return SubprocessCommand(["git", *args], **kwargs)
g = GitDeferred(dir=dir_type(tmp_path))
cmd = g.run(["help"])
assert g.dir == tmp_path
assert cmd.args == ["git", "help"]
assert cmd.run(capture_output=True, text=True).stdout.startswith(
"usage: git [--version] [--help] [-C <path>]"
)