Merge pull request #48 from jnothman/assert_frame_equal
[MRG] Use assert_frame_equal for more informative errors in testspull/41/merge
commit
83f816f104
|
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
from pandas.testing import assert_frame_equal
|
||||||
|
|
||||||
import camelot
|
import camelot
|
||||||
from camelot.core import Table, TableList
|
from camelot.core import Table, TableList
|
||||||
|
|
@ -26,10 +27,10 @@ def test_password():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "health_protected.pdf")
|
filename = os.path.join(testdir, "health_protected.pdf")
|
||||||
tables = camelot.read_pdf(filename, password="ownerpass", flavor="stream")
|
tables = camelot.read_pdf(filename, password="ownerpass", flavor="stream")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
tables = camelot.read_pdf(filename, password="userpass", flavor="stream")
|
tables = camelot.read_pdf(filename, password="userpass", flavor="stream")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream():
|
def test_stream():
|
||||||
|
|
@ -37,7 +38,7 @@ def test_stream():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "health.pdf")
|
filename = os.path.join(testdir, "health.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream")
|
tables = camelot.read_pdf(filename, flavor="stream")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_table_rotated():
|
def test_stream_table_rotated():
|
||||||
|
|
@ -45,11 +46,11 @@ def test_stream_table_rotated():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "clockwise_table_2.pdf")
|
filename = os.path.join(testdir, "clockwise_table_2.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream")
|
tables = camelot.read_pdf(filename, flavor="stream")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
filename = os.path.join(testdir, "anticlockwise_table_2.pdf")
|
filename = os.path.join(testdir, "anticlockwise_table_2.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream")
|
tables = camelot.read_pdf(filename, flavor="stream")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_two_tables():
|
def test_stream_two_tables():
|
||||||
|
|
@ -71,7 +72,7 @@ def test_stream_table_regions():
|
||||||
tables = camelot.read_pdf(
|
tables = camelot.read_pdf(
|
||||||
filename, flavor="stream", table_regions=["320,460,573,335"]
|
filename, flavor="stream", table_regions=["320,460,573,335"]
|
||||||
)
|
)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_table_areas():
|
def test_stream_table_areas():
|
||||||
|
|
@ -81,7 +82,7 @@ def test_stream_table_areas():
|
||||||
tables = camelot.read_pdf(
|
tables = camelot.read_pdf(
|
||||||
filename, flavor="stream", table_areas=["320,500,573,335"]
|
filename, flavor="stream", table_areas=["320,500,573,335"]
|
||||||
)
|
)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_columns():
|
def test_stream_columns():
|
||||||
|
|
@ -91,7 +92,7 @@ def test_stream_columns():
|
||||||
tables = camelot.read_pdf(
|
tables = camelot.read_pdf(
|
||||||
filename, flavor="stream", columns=["67,180,230,425,475"], row_tol=10
|
filename, flavor="stream", columns=["67,180,230,425,475"], row_tol=10
|
||||||
)
|
)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_split_text():
|
def test_stream_split_text():
|
||||||
|
|
@ -104,7 +105,7 @@ def test_stream_split_text():
|
||||||
columns=["72,95,209,327,442,529,566,606,683"],
|
columns=["72,95,209,327,442,529,566,606,683"],
|
||||||
split_text=True,
|
split_text=True,
|
||||||
)
|
)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_flag_size():
|
def test_stream_flag_size():
|
||||||
|
|
@ -112,7 +113,7 @@ def test_stream_flag_size():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "superscript.pdf")
|
filename = os.path.join(testdir, "superscript.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream", flag_size=True)
|
tables = camelot.read_pdf(filename, flavor="stream", flag_size=True)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_strip_text():
|
def test_stream_strip_text():
|
||||||
|
|
@ -120,7 +121,7 @@ def test_stream_strip_text():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "detect_vertical_false.pdf")
|
filename = os.path.join(testdir, "detect_vertical_false.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream", strip_text=" ,\n")
|
tables = camelot.read_pdf(filename, flavor="stream", strip_text=" ,\n")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_edge_tol():
|
def test_stream_edge_tol():
|
||||||
|
|
@ -128,7 +129,7 @@ def test_stream_edge_tol():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "edge_tol.pdf")
|
filename = os.path.join(testdir, "edge_tol.pdf")
|
||||||
tables = camelot.read_pdf(filename, flavor="stream", edge_tol=500)
|
tables = camelot.read_pdf(filename, flavor="stream", edge_tol=500)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_stream_layout_kwargs():
|
def test_stream_layout_kwargs():
|
||||||
|
|
@ -138,7 +139,7 @@ def test_stream_layout_kwargs():
|
||||||
tables = camelot.read_pdf(
|
tables = camelot.read_pdf(
|
||||||
filename, flavor="stream", layout_kwargs={"detect_vertical": False}
|
filename, flavor="stream", layout_kwargs={"detect_vertical": False}
|
||||||
)
|
)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice():
|
def test_lattice():
|
||||||
|
|
@ -148,7 +149,7 @@ def test_lattice():
|
||||||
testdir, "tabula/icdar2013-dataset/competition-dataset-us/us-030.pdf"
|
testdir, "tabula/icdar2013-dataset/competition-dataset-us/us-030.pdf"
|
||||||
)
|
)
|
||||||
tables = camelot.read_pdf(filename, pages="2")
|
tables = camelot.read_pdf(filename, pages="2")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_table_rotated():
|
def test_lattice_table_rotated():
|
||||||
|
|
@ -156,11 +157,11 @@ def test_lattice_table_rotated():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "clockwise_table_1.pdf")
|
filename = os.path.join(testdir, "clockwise_table_1.pdf")
|
||||||
tables = camelot.read_pdf(filename)
|
tables = camelot.read_pdf(filename)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
filename = os.path.join(testdir, "anticlockwise_table_1.pdf")
|
filename = os.path.join(testdir, "anticlockwise_table_1.pdf")
|
||||||
tables = camelot.read_pdf(filename)
|
tables = camelot.read_pdf(filename)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_two_tables():
|
def test_lattice_two_tables():
|
||||||
|
|
@ -179,7 +180,7 @@ def test_lattice_table_regions():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "table_region.pdf")
|
filename = os.path.join(testdir, "table_region.pdf")
|
||||||
tables = camelot.read_pdf(filename, table_regions=["170,370,560,270"])
|
tables = camelot.read_pdf(filename, table_regions=["170,370,560,270"])
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_table_areas():
|
def test_lattice_table_areas():
|
||||||
|
|
@ -187,7 +188,7 @@ def test_lattice_table_areas():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "twotables_2.pdf")
|
filename = os.path.join(testdir, "twotables_2.pdf")
|
||||||
tables = camelot.read_pdf(filename, table_areas=["80,693,535,448"])
|
tables = camelot.read_pdf(filename, table_areas=["80,693,535,448"])
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_process_background():
|
def test_lattice_process_background():
|
||||||
|
|
@ -195,7 +196,7 @@ def test_lattice_process_background():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "background_lines_1.pdf")
|
filename = os.path.join(testdir, "background_lines_1.pdf")
|
||||||
tables = camelot.read_pdf(filename, process_background=True)
|
tables = camelot.read_pdf(filename, process_background=True)
|
||||||
assert df.equals(tables[1].df)
|
assert_frame_equal(df, tables[1].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_copy_text():
|
def test_lattice_copy_text():
|
||||||
|
|
@ -203,7 +204,7 @@ def test_lattice_copy_text():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "row_span_1.pdf")
|
filename = os.path.join(testdir, "row_span_1.pdf")
|
||||||
tables = camelot.read_pdf(filename, line_scale=60, copy_text="v")
|
tables = camelot.read_pdf(filename, line_scale=60, copy_text="v")
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_lattice_shift_text():
|
def test_lattice_shift_text():
|
||||||
|
|
@ -271,7 +272,7 @@ def test_arabic():
|
||||||
|
|
||||||
filename = os.path.join(testdir, "tabula/arabic.pdf")
|
filename = os.path.join(testdir, "tabula/arabic.pdf")
|
||||||
tables = camelot.read_pdf(filename)
|
tables = camelot.read_pdf(filename)
|
||||||
assert df.equals(tables[0].df)
|
assert_frame_equal(df, tables[0].df)
|
||||||
|
|
||||||
|
|
||||||
def test_table_order():
|
def test_table_order():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue