Skip to content

Commit d373954

Browse files
committed
mask: fix test & improve error messages
Resolves: #188 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent e9f38cd commit d373954

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/pkgdev/scripts/pkgdev_mask.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ def _mask_validate(parser, namespace):
101101
atoms = set()
102102
maintainers = set()
103103

104-
namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs)))
104+
try:
105+
namespace.bugs = list(map(int, dict.fromkeys(namespace.bugs)))
106+
except ValueError:
107+
parser.error("argument -b/--bug: invalid integer value")
108+
if min(namespace.bugs, default=1) < 1:
109+
parser.error("argument -b/--bug: must be >= 1")
105110

106111
if not namespace.rites and namespace.file_bug:
107112
mask.error("bug filing requires last rites")

tests/scripts/test_pkgdev_mask.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def test_mask_bugs(self):
337337
for bug_nums, expected in [
338338
(["42"], "Bug #42."),
339339
(["42", "43"], "Bugs #42, #43."),
340+
(["42,43", "43"], "Bugs #42, #43."),
340341
]:
341342
args = []
342343
for bug_num in bug_nums:
@@ -361,7 +362,7 @@ def test_mask_bugs(self):
361362

362363
def test_mask_bug_bad(self, capsys, tool):
363364
for arg, expected in [("-1", "must be >= 1"), ("foo", "invalid integer value")]:
364-
with pytest.raises(SystemExit):
365+
with pytest.raises(SystemExit), chdir(pjoin(self.repo.path)):
365366
tool.parse_args(["mask", "--bug", arg])
366367
out, err = capsys.readouterr()
367368
assert err.strip() == f"pkgdev mask: error: argument -b/--bug: {expected}"

0 commit comments

Comments
 (0)