From 70733c047bb80c8e3496af7e15e5443f6ebbe3c5 Mon Sep 17 00:00:00 2001 From: David Dalcino Date: Thu, 1 Jul 2021 12:03:26 -0700 Subject: [PATCH] Add tests for `install`, `doc`, `list` --- tests/test_cli.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index dfbcb78..89799d4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -59,7 +59,7 @@ def test_cli_check_version(): @pytest.mark.parametrize( "invalid_version", - ("5.15", "five-dot-fifteen", "5"), + ("5.15", "five-dot-fifteen", "5", "5.5.5.5"), ) def test_cli_invalid_version(capsys, invalid_version): """Checks that invalid version strings are handled properly""" @@ -70,20 +70,22 @@ def test_cli_invalid_version(capsys, invalid_version): cli = aqt.installer.Cli() cli._setup_settings() - with pytest.raises(SystemExit) as pytest_wrapped_e: - cli = aqt.installer.Cli() - cli.run(["install", invalid_version, "mac", "desktop"]) - assert pytest_wrapped_e.type == SystemExit - assert pytest_wrapped_e.value.code == 1 - out, err = capsys.readouterr() - sys.stdout.write(out) - sys.stderr.write(err) matcher = re.compile( r"^aqtinstall\(aqt\) v.* on Python 3.*\n" r".*Invalid version: '" + invalid_version + r"'! Please use the form '5\.X\.Y'\.\n.*" ) - assert matcher.match(err) + + for cmd in "install", "doc", "list": + with pytest.raises(SystemExit) as pytest_wrapped_e: + cli = aqt.installer.Cli() + cli.run([cmd, invalid_version, "mac", "desktop"]) + assert pytest_wrapped_e.type == SystemExit + assert pytest_wrapped_e.value.code == 1 + out, err = capsys.readouterr() + sys.stdout.write(out) + sys.stderr.write(err) + assert matcher.match(err) def test_cli_check_mirror():