Merge pull request #246 from camelot-dev/use-explicit-backends

Use PopplerBackend and GhostscriptBackend in test_plotting.py
pull/249/head
Vinayak Mehta 2021-07-06 03:06:50 +05:30 committed by GitHub
commit d39ca4502b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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")