Refactor code style and improve documentation
- Standardized string quotes to single quotes across all files. - Added docstrings to several functions and classes for better clarity. - Updated mypy configuration in pyproject.toml for enhanced type checking. - Ignored specific linting rules for test files in ruff configuration. - Improved error messages in exception handling for better user feedback. - Cleaned up code formatting and structure for consistency.
This commit is contained in:
+8
-8
@@ -13,19 +13,19 @@ def test_cli_prints_downloaded_path(
|
||||
capsys: pytest.CaptureFixture[str],
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
expected_path = tmp_path / "video.mp4"
|
||||
expected_path = tmp_path / 'video.mp4'
|
||||
|
||||
def fake_download_to_path(**kwargs: object) -> Path:
|
||||
del kwargs
|
||||
return expected_path
|
||||
|
||||
monkeypatch.setattr(cli, "download_to_path", fake_download_to_path)
|
||||
monkeypatch.setattr(cli, 'download_to_path', fake_download_to_path)
|
||||
|
||||
exit_code = cli.main(
|
||||
[
|
||||
"https://youtube.com/shorts/example",
|
||||
"cookies.txt",
|
||||
"--output-dir",
|
||||
'https://youtube.com/shorts/example',
|
||||
'cookies.txt',
|
||||
'--output-dir',
|
||||
str(tmp_path),
|
||||
]
|
||||
)
|
||||
@@ -39,11 +39,11 @@ 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")
|
||||
raise InvalidSessionError('session error')
|
||||
|
||||
monkeypatch.setattr(cli, "download_to_path", 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"])
|
||||
cli.main(['https://youtube.com/shorts/example', 'cookies.txt'])
|
||||
|
||||
assert exc_info.value.code == 1
|
||||
|
||||
Reference in New Issue
Block a user