Skip to content

Commit 2b43b82

Browse files
authored
[CHANGED FILE/DIR: tests/test_cargo_install.py] DeepSource-oi - style: format code with Black and Ruff Formatter (#70)
2 parents 083501c + 1be00de commit 2b43b82

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tests/test_cargo_install.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,29 @@
77
validate_library_name,
88
)
99

10+
1011
def test_find_cargo_toml_exists(tmp_path, mock_os_path_exists):
1112
(tmp_path / "Cargo.toml").touch()
1213
mock_os_path_exists.return_value = True
1314
result = find_cargo_toml(str(tmp_path))
1415
assert result == str(tmp_path / "Cargo.toml")
1516

17+
1618
def test_find_cargo_toml_not_found():
1719
result = find_cargo_toml()
1820
assert result is None
1921

22+
2023
def test_validate_library_name_valid():
2124
assert validate_library_name("serde") is True
2225

26+
2327
def test_validate_library_name_invalid(capsys):
2428
assert validate_library_name("serde;malicious") is False
2529
captured = capsys.readouterr()
2630
assert "Invalid library name: serde;malicious" in captured.out
2731

32+
2833
def test_check_cargo_installed(mock_shutil_which, capsys):
2934
mock_shutil_which.return_value = "/usr/bin/cargo"
3035
assert check_cargo_installed() is True
@@ -34,24 +39,30 @@ def test_check_cargo_installed(mock_shutil_which, capsys):
3439
captured = capsys.readouterr()
3540
assert "cargo is not installed or not found in PATH" in captured.out
3641

37-
def test_cargo_install_success(tmp_path, mock_subprocess_run, mock_os_chdir, capsys):
42+
43+
def test_cargo_install_success(tmp_path, mock_subprocess_run, mock_os_chdir, capsys):
3844
(tmp_path / "Cargo.toml").touch()
39-
mock_subprocess_run.return_value = MagicMock(returncode=0, stdout="Added serde", stderr="")
45+
mock_subprocess_run.return_value = MagicMock(
46+
returncode=0, stdout="Added serde", stderr=""
47+
)
4048
cargo_install(["serde"])
4149
captured = capsys.readouterr()
4250
assert "Running cargo add serde ..." in captured.out
4351
assert "Cargo output:\nAdded serde" in captured.out
4452
mock_os_chdir.assert_called()
4553

46-
def test_cargo_install_failure(tmp_path, mock_subprocess_run, capsys):
54+
55+
def test_cargo_install_failure(tmp_path, mock_subprocess_run, capsys):
4756
(tmp_path / "Cargo.toml").touch()
4857
mock_subprocess_run.side_effect = subprocess.CalledProcessError(
49-
returncode=1, cmd=["cargo", "add", "serde"], output="", stderr="Error: invalid crate"
58+
returncode=1,
59+
cmd=["cargo", "add", "serde"],
60+
output="",
61+
stderr="Error: invalid crate",
5062
)
5163
cargo_install(["serde"])
5264
captured = capsys.readouterr()
5365
if "Failed to install serde" not in captured.out:
5466
raise AssertionError
5567
if "stderr:\nError: invalid crate" not in captured.out:
5668
raise AssertionError
57-

0 commit comments

Comments
 (0)