From 13da1a07fddf2413a54dfc82f1dea4765d669683 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Wed, 23 Sep 2026 09:37:23 +0800 Subject: [PATCH] Allow new output paths in CLI --- pytest/test_cli.py | 17 +++++++++++++++++ uncompyle6/bin/uncompile.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pytest/test_cli.py diff --git a/pytest/test_cli.py b/pytest/test_cli.py new file mode 100644 index 000000000..78cba008e --- /dev/null +++ b/pytest/test_cli.py @@ -0,0 +1,17 @@ +from click.testing import CliRunner + +from uncompyle6.bin import uncompile + + +def test_output_option_accepts_new_file(tmp_path, monkeypatch): + input_path = tmp_path / "input.pyc" + output_path = tmp_path / "new-output.py" + input_path.write_bytes(b"") + + monkeypatch.setattr(uncompile, "main", lambda *args, **kwargs: (0, 0, 0, 0)) + result = CliRunner().invoke( + uncompile.main_bin, + ["--output", str(output_path), str(input_path)], + ) + + assert result.exit_code == 0 diff --git a/uncompyle6/bin/uncompile.py b/uncompyle6/bin/uncompile.py index 3fc7fc332..8ff743531 100755 --- a/uncompyle6/bin/uncompile.py +++ b/uncompyle6/bin/uncompile.py @@ -120,7 +120,7 @@ def usage(): "-o", "outfile", type=click.Path( - exists=True, file_okay=True, dir_okay=True, writable=True, resolve_path=True + exists=False, file_okay=True, dir_okay=True, writable=True, resolve_path=True ), required=False, )