[MRG + 1] Add tests for repr (#128)

* add tests for repr

* remove repr for Cell

* add round for repr of Cell

* change decimal places to 2

* change tests for 2 decimal places
pull/2/head
Vaibhav Mule 2018-10-05 20:19:24 +05:30 committed by Vinayak Mehta
parent f13337d50a
commit c53ea795fd
2 changed files with 9 additions and 1 deletions

View File

@ -71,7 +71,7 @@ class Cell(object):
def __repr__(self): def __repr__(self):
return '<Cell x1={} y1={} x2={} y2={}>'.format( return '<Cell x1={} y1={} x2={} y2={}>'.format(
self.x1, self.y1, self.x2, self.y2) round(self.x1, 2), round(self.y1, 2), round(self.x2, 2), round(self.y2, 2))
@property @property
def text(self): def text(self):

View File

@ -138,3 +138,11 @@ def test_lattice_shift_text():
tables = camelot.read_pdf(filename, line_size_scaling=40, shift_text=['r', 'b']) tables = camelot.read_pdf(filename, line_size_scaling=40, shift_text=['r', 'b'])
assert df_rb.equals(tables[0].df) assert df_rb.equals(tables[0].df)
def test_repr():
filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename)
assert repr(tables) == "<TableList n=1>"
assert repr(tables[0]) == "<Table shape=(7, 7)>"
assert repr(tables[0].cells[0][0]) == "<Cell x1=120.48 y1=218.42 x2=164.64 y2=233.89>"