Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
test: use pytest temp dir for tests (#1006)
NTFSvolumeb7a0884278e9
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex b1a5f8920..b76217d57 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -3,22 +3,26 @@ import sysfrom cyberdrop_dl import env-def main(*, profiling: bool = False, ask: bool = True):+def main(*, profiling: bool = False, ask: bool = True) -> None:if not (profiling or env.PROFILING):- return run()+ return actual_main()from cyberdrop_dl.profiling import profile- profile(run, ask)+ profile(actual_main, ask)-def run() -> None:+def actual_main() -> None:+ sys.exit(run())+++def run() -> str | int:try:from cyberdrop_dl.director import Directordirector = Director()- sys.exit(director.run())+ return director.run()except KeyboardInterrupt:- sys.exit("\nKeyboardInterrupt")+ return "\nKeyboardInterrupt"if __name__ == "__main__":diff --git a/tests/test_startup.py b/tests/test_startup.pyindex 422117be3..d97229e74 100644--- a/tests/test_startup.py+++ b/tests/test_startup.py@@ -1,29 +1,35 @@import sys+from pathlib import Pathimport pytest-from cyberdrop_dl.main import main+from cyberdrop_dl.main import runfrom cyberdrop_dl.ui.program_ui import ProgramUI-def test_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]):[email protected](autouse=True)+def test_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.chdir(tmp_path)+++def test_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:# This is just to test that cyberdrop is able to run in the current python versionmsg = "main UI started successfully"- def main_ui(*_):+ def main_ui(*_) -> None:print(msg)monkeypatch.setattr(sys, "argv", ["pytest", "--disable-cache"])monkeypatch.setattr(ProgramUI, "__init__", main_ui)- main(profiling=True, ask=False)+ run()captured = capsys.readouterr()output = captured.outassert msg in output-def test_async_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]):+def test_async_startup(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None:monkeypatch.setattr(sys, "argv", ["pytest", "--download"])- main(profiling=True, ask=False)+ run()captured = capsys.readouterr()output = captured.outassert "Finished downloading. Enjoy :)" in output