From 8775ce6ee1cd818e0c02de14c45ab7aa7f73afec Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Tue, 28 May 2024 19:29:07 +0200 Subject: [PATCH] Fix error on error in usecase testing --- tests/test_usecases.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_usecases.py b/tests/test_usecases.py index 516971b..21490cd 100644 --- a/tests/test_usecases.py +++ b/tests/test_usecases.py @@ -36,11 +36,12 @@ def run_usecase(monkeypatch, capsys, usecase, bash): result = {} if err != '': result = 'Errors encountered while running usecase %s:%d: %s' % (file, lineno, err) - if out != '': - for line in out.split('\n'): - if expr.match(line) is None: - raise Exception('Unable to match output for usecase %s:%d: %s' % (file, lineno, line)) - result[expr.match(line).group(2)] = line # type: ignore + else: + if out != '': + for line in out.split('\n'): + if expr.match(line) is None: + raise Exception('Unable to match output for usecase %s:%d: %s' % (file, lineno, line)) + result[expr.match(line).group(2)] = line # type: ignore else: result = 'user-error' return Usecase(file, lineno, bash[0], doc, prog, argv, type, result)