Refactor code structure for improved readability and maintainability
This commit is contained in:
+8
-2
@@ -14,7 +14,12 @@ def test_cli_prints_downloaded_path(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
expected_path = tmp_path / "video.mp4"
|
||||
monkeypatch.setattr(cli, "download", lambda **kwargs: expected_path)
|
||||
|
||||
def fake_download_to_path(**kwargs: object) -> Path:
|
||||
del kwargs
|
||||
return expected_path
|
||||
|
||||
monkeypatch.setattr(cli, "download_to_path", fake_download_to_path)
|
||||
|
||||
exit_code = cli.main(
|
||||
[
|
||||
@@ -33,9 +38,10 @@ def test_cli_prints_downloaded_path(
|
||||
|
||||
def test_cli_exits_with_error(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
def raise_error(**kwargs: object) -> Path:
|
||||
del kwargs
|
||||
raise InvalidSessionError("session error")
|
||||
|
||||
monkeypatch.setattr(cli, "download", raise_error)
|
||||
monkeypatch.setattr(cli, "download_to_path", raise_error)
|
||||
|
||||
with pytest.raises(SystemExit) as exc_info:
|
||||
cli.main(["https://youtube.com/shorts/example", "cookies.txt"])
|
||||
|
||||
Reference in New Issue
Block a user