Use PopplerBackend and GhostscriptBackend in test_plotting.py

pull/246/head
Vinayak Mehta 2021-07-06 02:58:41 +05:30
parent 2aa982b51d
commit 1dc8f4e241
No known key found for this signature in database
GPG Key ID: 2DE013537A15A9A4
1 changed files with 10 additions and 9 deletions

View File

@ -6,7 +6,8 @@ import sys
import pytest import pytest
import camelot import camelot
from camelot.backends.image_conversion import ImageConversionBackend from camelot.backends.poppler_backend import PopplerBackend
from camelot.backends.ghostscript_backend import GhostscriptBackend
testdir = os.path.dirname(os.path.abspath(__file__)) testdir = os.path.dirname(os.path.abspath(__file__))
@ -30,7 +31,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, backend=ImageConversionBackend("poppler", use_fallback=False)) tables = camelot.read_pdf(filename, backend=PopplerBackend())
return camelot.plot(tables[0], kind="contour") return camelot.plot(tables[0], kind="contour")
@ -40,7 +41,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", use_fallback=False)) tables = camelot.read_pdf(filename, backend=GhostscriptBackend())
return camelot.plot(tables[0], kind="contour") return camelot.plot(tables[0], kind="contour")
@ -54,7 +55,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, backend=ImageConversionBackend("poppler", use_fallback=False)) tables = camelot.read_pdf(filename, backend=PopplerBackend())
return camelot.plot(tables[0], kind="line") return camelot.plot(tables[0], kind="line")
@ -64,14 +65,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", use_fallback=False)) tables = camelot.read_pdf(filename, backend=GhostscriptBackend())
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, backend=ImageConversionBackend("poppler", use_fallback=False)) tables = camelot.read_pdf(filename, backend=PopplerBackend())
return camelot.plot(tables[0], kind="joint") return camelot.plot(tables[0], kind="joint")
@ -81,14 +82,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", use_fallback=False)) tables = camelot.read_pdf(filename, backend=GhostscriptBackend())
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, backend=ImageConversionBackend("poppler", use_fallback=False)) tables = camelot.read_pdf(filename, backend=PopplerBackend())
return camelot.plot(tables[0], kind="grid") return camelot.plot(tables[0], kind="grid")
@ -98,5 +99,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", use_fallback=False)) tables = camelot.read_pdf(filename, backend=GhostscriptBackend())
return camelot.plot(tables[0], kind="grid") return camelot.plot(tables[0], kind="grid")