From c53ea795fd425e92664bbfa7fe7979157530f123 Mon Sep 17 00:00:00 2001 From: Vaibhav Mule Date: Fri, 5 Oct 2018 20:19:24 +0530 Subject: [PATCH] [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 --- camelot/core.py | 2 +- tests/test_common.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/camelot/core.py b/camelot/core.py index 0a1898c..d6eb3d7 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -71,7 +71,7 @@ class Cell(object): def __repr__(self): return ''.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 def text(self): diff --git a/tests/test_common.py b/tests/test_common.py index 7039657..e872fb8 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -138,3 +138,11 @@ def test_lattice_shift_text(): tables = camelot.read_pdf(filename, line_size_scaling=40, shift_text=['r', 'b']) 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) == "" + assert repr(tables[0]) == "" + assert repr(tables[0].cells[0][0]) == ""