From 62b6cf3779e701b9ad7dccdcaed29281d5fbbfaa Mon Sep 17 00:00:00 2001 From: bosd Date: Thu, 17 Oct 2024 16:41:37 +0200 Subject: [PATCH] [FIX] Warning on test cli quiet --- tests/test_cli.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 3325018a..a3801152 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,5 +1,6 @@ import os import sys +import warnings from unittest import mock import pytest @@ -267,20 +268,25 @@ def test_cli_quiet(testdir): infile = os.path.join(testdir, "empty.pdf") outfile = os.path.join(tempdir, "empty.csv") runner = CliRunner() - - result = runner.invoke( - cli, ["--format", "csv", "--output", outfile, "stream", infile] - ) - assert "Found 0 tables" in result.output - - try: - result = runner.invoke( - cli, - ["--quiet", "--format", "csv", "--output", outfile, "stream", infile], - ) - except Warning as e: - warning_text = str(e) - pytest.fail(f"Unexpected warning: {warning_text}") + with warnings.catch_warnings(): + # the test should fail if any warning is thrown + # warnings.simplefilter("error") + try: + result = runner.invoke( + cli, + [ + "--quiet", + "--format", + "csv", + "--output", + outfile, + "stream", + infile, + ], + ) + except Warning as e: + warning_text = str(e) + pytest.fail(f"Unexpected warning: {warning_text}") def test_cli_lattice_plot_type():