Warn instead of raise, fix imports, and use skipif instead of skip
parent
f160c1d44d
commit
02f53e7654
|
|
@ -142,9 +142,10 @@ class Lattice(BaseParser):
|
|||
if isinstance(backend, str):
|
||||
if backend in BACKENDS.keys():
|
||||
if backend == "ghostscript":
|
||||
raise DeprecationWarning(
|
||||
warnings.warn(
|
||||
"'ghostscript' will be replaced by 'poppler' as the default image conversion"
|
||||
" backend in v0.12.0. You can try out 'poppler' with backend='poppler'."
|
||||
" backend in v0.12.0. You can try out 'poppler' with backend='poppler'.",
|
||||
DeprecationWarning
|
||||
)
|
||||
|
||||
return BACKENDS[backend]()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
|
||||
from camelot.cli import cli
|
||||
|
|
@ -11,7 +13,10 @@ from camelot.utils import TemporaryDirectory
|
|||
testdir = os.path.dirname(os.path.abspath(__file__))
|
||||
testdir = os.path.join(testdir, "files")
|
||||
|
||||
skip_on_windows = pytest.mark.skip(sys.platform.startswith("win"))
|
||||
skip_on_windows = pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Ghostscript not installed in Windows test environment",
|
||||
)
|
||||
|
||||
|
||||
def test_help_output():
|
||||
|
|
@ -38,7 +43,7 @@ def test_cli_lattice():
|
|||
cli, ["--format", "csv", "--output", outfile, "lattice", infile]
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert result.output == "Found 1 tables\n"
|
||||
assert "Found 1 tables" in result.output
|
||||
|
||||
result = runner.invoke(cli, ["--format", "csv", "lattice", infile])
|
||||
output_error = "Error: Please specify output file path using --output"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
import pandas as pd
|
||||
from pandas.testing import assert_frame_equal
|
||||
|
||||
|
|
@ -16,7 +17,10 @@ from .data import *
|
|||
testdir = os.path.dirname(os.path.abspath(__file__))
|
||||
testdir = os.path.join(testdir, "files")
|
||||
|
||||
skip_on_windows = pytest.mark.skip(sys.platform.startswith("win"))
|
||||
skip_on_windows = pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Ghostscript not installed in Windows test environment",
|
||||
)
|
||||
|
||||
|
||||
def test_version_generation():
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import pytest
|
||||
|
|
@ -12,7 +13,10 @@ testdir = os.path.dirname(os.path.abspath(__file__))
|
|||
testdir = os.path.join(testdir, "files")
|
||||
filename = os.path.join(testdir, "foo.pdf")
|
||||
|
||||
skip_on_windows = pytest.mark.skip(sys.platform.startswith("win"))
|
||||
skip_on_windows = pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Ghostscript not installed in Windows test environment",
|
||||
)
|
||||
|
||||
|
||||
def test_unknown_flavor():
|
||||
|
|
@ -87,7 +91,7 @@ def test_stream_equal_length():
|
|||
def test_image_warning():
|
||||
filename = os.path.join(testdir, "image.pdf")
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error")
|
||||
warnings.simplefilter("error", category=UserWarning)
|
||||
with pytest.raises(UserWarning) as e:
|
||||
tables = camelot.read_pdf(filename)
|
||||
assert (
|
||||
|
|
@ -117,7 +121,7 @@ def test_stream_no_tables_in_area():
|
|||
def test_lattice_no_tables_on_page():
|
||||
filename = os.path.join(testdir, "empty.pdf")
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error")
|
||||
warnings.simplefilter("error", category=UserWarning)
|
||||
with pytest.raises(UserWarning) as e:
|
||||
tables = camelot.read_pdf(filename, flavor="lattice")
|
||||
assert str(e.value) == "No tables found on page-1"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
import pandas as pd
|
||||
from pandas.testing import assert_frame_equal
|
||||
|
||||
|
|
@ -14,7 +16,10 @@ from .data import *
|
|||
testdir = os.path.dirname(os.path.abspath(__file__))
|
||||
testdir = os.path.join(testdir, "files")
|
||||
|
||||
skip_on_windows = pytest.mark.skip(sys.platform.startswith("win"))
|
||||
skip_on_windows = pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Ghostscript not installed in Windows test environment",
|
||||
)
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
|
|
|
|||
|
|
@ -10,7 +10,10 @@ import camelot
|
|||
testdir = os.path.dirname(os.path.abspath(__file__))
|
||||
testdir = os.path.join(testdir, "files")
|
||||
|
||||
skip_on_windows = pytest.mark.skip(sys.platform.startswith("win"))
|
||||
skip_on_windows = pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Ghostscript not installed in Windows test environment",
|
||||
)
|
||||
|
||||
|
||||
@skip_on_windows
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
import pandas as pd
|
||||
from pandas.testing import assert_frame_equal
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue