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 isinstance(backend, str):
|
||||||
if backend in BACKENDS.keys():
|
if backend in BACKENDS.keys():
|
||||||
if backend == "ghostscript":
|
if backend == "ghostscript":
|
||||||
raise DeprecationWarning(
|
warnings.warn(
|
||||||
"'ghostscript' will be replaced by 'poppler' as the default image conversion"
|
"'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]()
|
return BACKENDS[backend]()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
|
|
||||||
from camelot.cli import cli
|
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.dirname(os.path.abspath(__file__))
|
||||||
testdir = os.path.join(testdir, "files")
|
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():
|
def test_help_output():
|
||||||
|
|
@ -38,7 +43,7 @@ def test_cli_lattice():
|
||||||
cli, ["--format", "csv", "--output", outfile, "lattice", infile]
|
cli, ["--format", "csv", "--output", outfile, "lattice", infile]
|
||||||
)
|
)
|
||||||
assert result.exit_code == 0
|
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])
|
result = runner.invoke(cli, ["--format", "csv", "lattice", infile])
|
||||||
output_error = "Error: Please specify output file path using --output"
|
output_error = "Error: Please specify output file path using --output"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pandas.testing import assert_frame_equal
|
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.dirname(os.path.abspath(__file__))
|
||||||
testdir = os.path.join(testdir, "files")
|
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():
|
def test_version_generation():
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -12,7 +13,10 @@ testdir = os.path.dirname(os.path.abspath(__file__))
|
||||||
testdir = os.path.join(testdir, "files")
|
testdir = os.path.join(testdir, "files")
|
||||||
filename = os.path.join(testdir, "foo.pdf")
|
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():
|
def test_unknown_flavor():
|
||||||
|
|
@ -87,7 +91,7 @@ def test_stream_equal_length():
|
||||||
def test_image_warning():
|
def test_image_warning():
|
||||||
filename = os.path.join(testdir, "image.pdf")
|
filename = os.path.join(testdir, "image.pdf")
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("error")
|
warnings.simplefilter("error", category=UserWarning)
|
||||||
with pytest.raises(UserWarning) as e:
|
with pytest.raises(UserWarning) as e:
|
||||||
tables = camelot.read_pdf(filename)
|
tables = camelot.read_pdf(filename)
|
||||||
assert (
|
assert (
|
||||||
|
|
@ -117,7 +121,7 @@ def test_stream_no_tables_in_area():
|
||||||
def test_lattice_no_tables_on_page():
|
def test_lattice_no_tables_on_page():
|
||||||
filename = os.path.join(testdir, "empty.pdf")
|
filename = os.path.join(testdir, "empty.pdf")
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.simplefilter("error")
|
warnings.simplefilter("error", category=UserWarning)
|
||||||
with pytest.raises(UserWarning) as e:
|
with pytest.raises(UserWarning) as e:
|
||||||
tables = camelot.read_pdf(filename, flavor="lattice")
|
tables = camelot.read_pdf(filename, flavor="lattice")
|
||||||
assert str(e.value) == "No tables found on page-1"
|
assert str(e.value) == "No tables found on page-1"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pandas.testing import assert_frame_equal
|
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.dirname(os.path.abspath(__file__))
|
||||||
testdir = os.path.join(testdir, "files")
|
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
|
@skip_on_windows
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,10 @@ import camelot
|
||||||
testdir = os.path.dirname(os.path.abspath(__file__))
|
testdir = os.path.dirname(os.path.abspath(__file__))
|
||||||
testdir = os.path.join(testdir, "files")
|
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
|
@skip_on_windows
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from pandas.testing import assert_frame_equal
|
from pandas.testing import assert_frame_equal
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue