diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 09254e6..04a7cf8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,28 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install camelot with dependencies + run: | + make install + - name: Test with pytest + run: | + make test + + test_latest: + name: Test on ${{ matrix.os }} with Python 3.9 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.9] steps: - uses: actions/checkout@v2 diff --git a/camelot/backends/image_conversion.py b/camelot/backends/image_conversion.py index 004bce7..f79c236 100644 --- a/camelot/backends/image_conversion.py +++ b/camelot/backends/image_conversion.py @@ -1,11 +1,8 @@ # -*- coding: utf-8 -*- -import logging - from .poppler_backend import PopplerBackend from .ghostscript_backend import GhostscriptBackend -logger = logging.getLogger("camelot") backends = {"poppler": PopplerBackend, "ghostscript": GhostscriptBackend} @@ -23,9 +20,7 @@ class ImageConversionBackend(object): converter = backends[self.backend]() converter.convert(pdf_path, png_path) except Exception as e: - logger.info( - f"Image conversion backend '{self.backend}' failed with '{str(e)}'" - ) + import sys if self.use_fallback: for fallback in self.fallbacks: @@ -35,10 +30,13 @@ class ImageConversionBackend(object): converter = backends[fallback]() converter.convert(pdf_path, png_path) except Exception as e: - logger.info( - f"Image conversion backend '{fallback}' failed with '{str(e)}'" - ) + raise type(e)( + str(e) + f" with image conversion backend '{fallback}'" + ).with_traceback(sys.exc_info()[2]) continue else: - logger.info(f"Image conversion backend '{fallback}' succeeded") break + else: + raise type(e)( + str(e) + f" with image conversion backend '{self.backend}'" + ).with_traceback(sys.exc_info()[2]) diff --git a/tests/test_image_conversion_backend.py b/tests/test_image_conversion_backend.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 39525d0..5573c34 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -36,7 +36,7 @@ def test_lattice_contour_plot_poppler(): @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) def test_lattice_contour_plot_ghostscript(): filename = os.path.join(testdir, "foo.pdf") - tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript')) + tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) return camelot.plot(tables[0], kind="contour") @@ -57,7 +57,7 @@ def test_line_plot_poppler(): @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) def test_line_plot_ghostscript(): filename = os.path.join(testdir, "foo.pdf") - tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript')) + tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) return camelot.plot(tables[0], kind="line") @@ -71,7 +71,7 @@ def test_joint_plot_poppler(): @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) def test_joint_plot_ghostscript(): filename = os.path.join(testdir, "foo.pdf") - tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript')) + tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) return camelot.plot(tables[0], kind="joint") @@ -85,5 +85,5 @@ def test_grid_plot_poppler(): @pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True) def test_grid_plot_ghostscript(): filename = os.path.join(testdir, "foo.pdf") - tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript')) + tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript")) return camelot.plot(tables[0], kind="grid")