File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed
Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ """Tests for libvcs._internal.run."""
2+
3+ from __future__ import annotations
4+
5+ import pathlib
6+
7+ from libvcs ._internal .run import _normalize_command_args
8+
9+
10+ def test_normalize_command_args_keeps_scalar_string () -> None :
11+ """Scalar strings should remain a single subprocess argument."""
12+ assert _normalize_command_args ("status" ) == ["status" ]
13+
14+
15+ def test_normalize_command_args_keeps_scalar_bytes () -> None :
16+ """Scalar bytes should remain a single subprocess argument."""
17+ assert _normalize_command_args (b"status" ) == [b"status" ]
18+
19+
20+ def test_normalize_command_args_expands_sequence () -> None :
21+ """Sequences should be expanded element by element."""
22+ assert _normalize_command_args (["status" , "--short" ]) == ["status" , "--short" ]
23+
24+
25+ def test_normalize_command_args_coerces_pathlike () -> None :
26+ """Path-like values should be converted with os.fspath semantics."""
27+ path = pathlib .Path ("example" )
28+
29+ assert _normalize_command_args (path ) == ["example" ]
30+ assert _normalize_command_args ([path , "status" ]) == ["example" , "status" ]
Original file line number Diff line number Diff line change @@ -35,6 +35,15 @@ def test_git_init_basic(tmp_path: pathlib.Path) -> None:
3535 assert (tmp_path / ".git" ).is_dir ()
3636
3737
38+ def test_git_run_accepts_scalar_string (tmp_path : pathlib .Path ) -> None :
39+ """Git run() should not split scalar command strings."""
40+ repo = git .Git (path = tmp_path )
41+
42+ result = repo .run ("--version" )
43+
44+ assert result .startswith ("git version " )
45+
46+
3847def test_git_init_bare (tmp_path : pathlib .Path ) -> None :
3948 """Test git init with bare repository."""
4049 repo = git .Git (path = tmp_path )
Original file line number Diff line number Diff line change 1+ """Tests for libvcs.cmd.hg."""
2+
3+ from __future__ import annotations
4+
5+ import pathlib
6+ import shutil
7+
8+ import pytest
9+
10+ from libvcs .cmd .hg import Hg
11+
12+ if not shutil .which ("hg" ):
13+ pytestmark = pytest .mark .skip (reason = "hg is not available" )
14+
15+
16+ def test_hg_run_accepts_scalar_string (tmp_path : pathlib .Path ) -> None :
17+ """Mercurial run() should not split scalar command strings."""
18+ repo = Hg (path = tmp_path )
19+
20+ result = repo .run ("help" )
21+
22+ assert "Mercurial Distributed SCM" in result
Original file line number Diff line number Diff line change 1+ """Tests for libvcs.cmd.svn."""
2+
3+ from __future__ import annotations
4+
5+ import pathlib
6+ import shutil
7+
8+ import pytest
9+
10+ from libvcs .cmd .svn import Svn
11+
12+ if not shutil .which ("svn" ):
13+ pytestmark = pytest .mark .skip (reason = "svn is not available" )
14+
15+
16+ def test_svn_run_accepts_scalar_string (tmp_path : pathlib .Path ) -> None :
17+ """Subversion run() should not split scalar command strings."""
18+ repo = Svn (path = tmp_path )
19+
20+ result = repo .run ("help" )
21+
22+ assert "usage: svn <subcommand> [options] [args]" in result
You can’t perform that action at this time.
0 commit comments