Don't use fallback for image conversion backend tests

pull/198/head
Vinayak Mehta 2021-07-04 20:22:32 +05:30
parent c3b0fa30dc
commit 458181cd1d
No known key found for this signature in database
GPG Key ID: 2DE013537A15A9A4
2 changed files with 46 additions and 21 deletions

View File

@ -53,7 +53,9 @@ def test_password():
def test_repr_poppler(): def test_repr_poppler():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename) tables = camelot.read_pdf(
filename, backend=ImageConversionBackend(backend="poppler", use_fallback=False)
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>"
@ -65,7 +67,8 @@ def test_repr_ghostscript():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf( tables = camelot.read_pdf(
filename, backend=ImageConversionBackend(backend="ghostscript") filename,
backend=ImageConversionBackend(backend="ghostscript", use_fallback=False),
) )
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
@ -74,7 +77,9 @@ def test_repr_ghostscript():
def test_url_poppler(): def test_url_poppler():
url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf"
tables = camelot.read_pdf(url) tables = camelot.read_pdf(
url, backend=ImageConversionBackend(backend="poppler", use_fallback=False)
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>"
@ -86,7 +91,7 @@ def test_url_ghostscript():
url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf"
tables = camelot.read_pdf( tables = camelot.read_pdf(
url, backend=ImageConversionBackend(backend="ghostscript") url, backend=ImageConversionBackend(backend="ghostscript", use_fallback=False)
) )
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
@ -95,17 +100,27 @@ def test_url_ghostscript():
def test_pages_poppler(): def test_pages_poppler():
url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf"
tables = camelot.read_pdf(url) tables = camelot.read_pdf(
url, backend=ImageConversionBackend(backend="poppler", use_fallback=False)
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>"
tables = camelot.read_pdf(url, pages="1-end") tables = camelot.read_pdf(
url,
pages="1-end",
backend=ImageConversionBackend(backend="poppler", use_fallback=False),
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>"
tables = camelot.read_pdf(url, pages="all") tables = camelot.read_pdf(
url,
pages="all",
backend=ImageConversionBackend(backend="poppler", use_fallback=False),
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>"
@ -116,20 +131,30 @@ def test_pages_ghostscript():
return True return True
url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf" url = "https://camelot-py.readthedocs.io/en/master/_static/pdf/foo.pdf"
tables = camelot.read_pdf(url) tables = camelot.read_pdf(
url, backend=ImageConversionBackend(backend="ghostscript", use_fallback=False)
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=218 x2=165 y2=234>"
tables = camelot.read_pdf(url, pages="1-end") tables = camelot.read_pdf(
url,
pages="1-end",
backend=ImageConversionBackend(backend="ghostscript", use_fallback=False),
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=218 x2=165 y2=234>"
tables = camelot.read_pdf(url, pages="all") tables = camelot.read_pdf(
url,
pages="all",
backend=ImageConversionBackend(backend="ghostscript", use_fallback=False),
)
assert repr(tables) == "<TableList n=1>" assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>" assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=219 x2=165 y2=234>" assert repr(tables[0].cells[0][0]) == "<Cell x1=120 y1=218 x2=165 y2=234>"
def test_table_order(): def test_table_order():

View File

@ -30,7 +30,7 @@ def test_textedge_plot():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_lattice_contour_plot_poppler(): def test_lattice_contour_plot_poppler():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("poppler", use_fallback=False))
return camelot.plot(tables[0], kind="contour") return camelot.plot(tables[0], kind="contour")
@ -40,7 +40,7 @@ def test_lattice_contour_plot_ghostscript():
pytest.skip("Skipping ghostscript test on Windows") pytest.skip("Skipping ghostscript test on Windows")
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript", use_fallback=False))
return camelot.plot(tables[0], kind="contour") return camelot.plot(tables[0], kind="contour")
@ -54,7 +54,7 @@ def test_stream_contour_plot():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_line_plot_poppler(): def test_line_plot_poppler():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("poppler", use_fallback=False))
return camelot.plot(tables[0], kind="line") return camelot.plot(tables[0], kind="line")
@ -64,14 +64,14 @@ def test_line_plot_ghostscript():
pytest.skip("Skipping ghostscript test on Windows") pytest.skip("Skipping ghostscript test on Windows")
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript", use_fallback=False))
return camelot.plot(tables[0], kind="line") return camelot.plot(tables[0], kind="line")
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_joint_plot_poppler(): def test_joint_plot_poppler():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("poppler", use_fallback=False))
return camelot.plot(tables[0], kind="joint") return camelot.plot(tables[0], kind="joint")
@ -81,14 +81,14 @@ def test_joint_plot_ghostscript():
pytest.skip("Skipping ghostscript test on Windows") pytest.skip("Skipping ghostscript test on Windows")
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript", use_fallback=False))
return camelot.plot(tables[0], kind="joint") return camelot.plot(tables[0], kind="joint")
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_grid_plot_poppler(): def test_grid_plot_poppler():
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("poppler", use_fallback=False))
return camelot.plot(tables[0], kind="grid") return camelot.plot(tables[0], kind="grid")
@ -98,5 +98,5 @@ def test_grid_plot_ghostscript():
pytest.skip("Skipping ghostscript test on Windows") pytest.skip("Skipping ghostscript test on Windows")
filename = os.path.join(testdir, "foo.pdf") filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript", use_fallback=False))
return camelot.plot(tables[0], kind="grid") return camelot.plot(tables[0], kind="grid")