diff --git a/tests/test_reports_accrual.py b/tests/test_reports_accrual.py index fec4b0e736bb0bc0fae2a9e9e58688af7a4a890e..a6c1c78d9845f1dc3c54db97cbea166fc7cb880b 100644 --- a/tests/test_reports_accrual.py +++ b/tests/test_reports_accrual.py @@ -590,12 +590,13 @@ def run_main(arglist, config=None): retcode = accrual.main(arglist, output, errors, config) return retcode, output, errors -def check_main_fails(arglist, config, error_flags, error_patterns): +def check_main_fails(arglist, config, error_flags): retcode, output, errors = run_main(arglist, config) assert retcode > 16 assert (retcode - 16) & error_flags - check_output(errors, error_patterns) assert not output.getvalue() + errors.seek(0) + return errors @pytest.mark.parametrize('arglist', [ ['--report-type=balance', 'entity=EarlyBird'], @@ -686,7 +687,8 @@ def test_main_aging_report(tmp_path, arglist): check_aging_ods(ods_file, None, recv_rows, pay_rows) def test_main_no_books(): - check_main_fails([], testutil.TestConfig(), 1 | 8, [ + errors = check_main_fails([], testutil.TestConfig(), 1 | 8) + testutil.check_lines_match(iter(errors), [ r':[01]: +no books to load in configuration\b', ]) @@ -695,15 +697,17 @@ def test_main_no_books(): ['505/99999'], ['entity=NonExistent'], ]) -def test_main_no_matches(arglist): - check_main_fails(arglist, None, 8, [ - r': WARNING: no matching entries found to report$', +def test_main_no_matches(arglist, caplog): + check_main_fails(arglist, None, 8) + testutil.check_logs_match(caplog, [ + ('WARNING', 'no matching entries found to report'), ]) -def test_main_no_rt(): +def test_main_no_rt(caplog): config = testutil.TestConfig( books_path=testutil.test_path('books/accruals.beancount'), ) - check_main_fails(['-t', 'out'], config, 4, [ - r': ERROR: unable to generate outgoing report: RT client is required\b', + check_main_fails(['-t', 'out'], config, 4) + testutil.check_logs_match(caplog, [ + ('ERROR', 'unable to generate outgoing report: RT client is required'), ])