Prevent taking max of an empty set

This commit is contained in:
Vinayak Mehta
2020-08-25 22:50:31 +05:30
parent 9087429501
commit 5d20d56e48
6 changed files with 67 additions and 43 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -160,8 +160,8 @@ def test_cli_output_format():
def test_cli_quiet():
with TemporaryDirectory() as tempdir:
infile = os.path.join(testdir, "blank.pdf")
outfile = os.path.join(tempdir, "blank.csv")
infile = os.path.join(testdir, "empty.pdf")
outfile = os.path.join(tempdir, "empty.csv")
runner = CliRunner()
result = runner.invoke(
+22 -4
View File
@@ -55,15 +55,33 @@ def test_image_warning():
)
def test_no_tables_found():
filename = os.path.join(testdir, "blank.pdf")
def test_lattice_no_tables_on_page():
filename = os.path.join(testdir, "empty.pdf")
with warnings.catch_warnings():
warnings.simplefilter("error")
with pytest.raises(UserWarning) as e:
tables = camelot.read_pdf(filename)
tables = camelot.read_pdf(filename, flavor="lattice")
assert str(e.value) == "No tables found on page-1"
def test_stream_no_tables_on_page():
filename = os.path.join(testdir, "empty.pdf")
with warnings.catch_warnings():
warnings.simplefilter("error")
with pytest.raises(UserWarning) as e:
tables = camelot.read_pdf(filename, flavor="stream")
assert str(e.value) == "No tables found on page-1"
def test_stream_no_tables_in_area():
filename = os.path.join(testdir, "only_page_number.pdf")
with warnings.catch_warnings():
warnings.simplefilter("error")
with pytest.raises(UserWarning) as e:
tables = camelot.read_pdf(filename, flavor="stream")
assert str(e.value) == "No tables found in table area 1"
def test_no_tables_found_logs_suppressed():
filename = os.path.join(testdir, "foo.pdf")
with warnings.catch_warnings():
@@ -77,7 +95,7 @@ def test_no_tables_found_logs_suppressed():
def test_no_tables_found_warnings_suppressed():
filename = os.path.join(testdir, "blank.pdf")
filename = os.path.join(testdir, "empty.pdf")
with warnings.catch_warnings():
# the test should fail if any warning is thrown
warnings.simplefilter("error")