diff options
author | 2024-06-02 22:18:05 +0300 | |
---|---|---|
committer | 2024-06-02 22:18:05 +0300 | |
commit | d37395418f44d5716a24d9cc84f8bf2d8bc084bb (patch) | |
tree | 7f1f80972060da29bcffdde7451d6f91a4438d5d | |
parent | mask: support comma separated bugs (diff) | |
download | pkgdev-d37395418f44d5716a24d9cc84f8bf2d8bc084bb.tar.gz pkgdev-d37395418f44d5716a24d9cc84f8bf2d8bc084bb.tar.bz2 pkgdev-d37395418f44d5716a24d9cc84f8bf2d8bc084bb.zip |
mask: fix test & improve error messages
Resolves: https://github.com/pkgcore/pkgdev/issues/188
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/pkgdev/scripts/pkgdev_mask.py | 7 | ||||
-rw-r--r-- | tests/scripts/test_pkgdev_mask.py | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py index 1d614a0..450c52c 100644 --- a/src/pkgdev/scripts/pkgdev_mask.py +++ b/src/pkgdev/scripts/pkgdev_mask.py @@ -101,7 +101,12 @@ def _mask_validate(parser, namespace): atoms = set() maintainers = set() - namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs))) + try: + namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs))) + except ValueError: + parser.error("argument -b/--bug: invalid integer value") + if min(namespace.bugs, default=1) < 1: + parser.error("argument -b/--bug: must be >= 1") if not namespace.rites and namespace.file_bug: mask.error("bug filing requires last rites") diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py index 8366ced..63d1e53 100644 --- a/tests/scripts/test_pkgdev_mask.py +++ b/tests/scripts/test_pkgdev_mask.py @@ -337,6 +337,7 @@ class TestPkgdevMask: for bug_nums, expected in [ (["42"], "Bug #42."), (["42", "43"], "Bugs #42, #43."), + (["42,43", "43"], "Bugs #42, #43."), ]: args = [] for bug_num in bug_nums: @@ -361,7 +362,7 @@ class TestPkgdevMask: def test_mask_bug_bad(self, capsys, tool): for arg, expected in [("-1", "must be >= 1"), ("foo", "invalid integer value")]: - with pytest.raises(SystemExit): + with pytest.raises(SystemExit), chdir(pjoin(self.repo.path)): tool.parse_args(["mask", "--bug", arg]) out, err = capsys.readouterr() assert err.strip() == f"pkgdev mask: error: argument -b/--bug: {expected}" |