Skip to content

Commit a5e7d7f

Browse files
committed
Remove pandas from dev requirements and tests
Results in needing one more # pragma: nocover statement, but on a simple line of code. See PR #253 for details and motivation.
1 parent 90f767f commit a5e7d7f

12 files changed

+51
-162
lines changed

pdfplumber/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def is_dataframe(collection):
163163

164164
def to_list(collection):
165165
if is_dataframe(collection):
166-
return collection.to_dict("records")
166+
return collection.to_dict("records") # pragma: nocover
167167
else:
168168
return list(collection)
169169

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pandas>=1.0.0
21
pytest
32
pytest-cov
43
pytest-parallel

tests/pdfs/pdffill-demo.pdf

-11.8 KB
Binary file not shown.

tests/test_basics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
import unittest
33
import pytest
4-
import pandas as pd
54
import pdfplumber
65
import sys, os
76

tests/test_ca_warn_report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
import unittest
3-
import pandas as pd
43
import pdfplumber
54
from pdfplumber import utils
65
from pdfplumber import table
@@ -37,7 +36,7 @@ def test_objects(self):
3736
assert len(self.pdf.figures)
3837
assert len(self.pdf.images)
3938

40-
def test_pandas(self):
39+
def test_parse(self):
4140

4241
rect_x0_clusters = utils.cluster_list([ r["x0"]
4342
for r in self.pdf.pages[1].rects ], tolerance=3)

tests/test_convert.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
import unittest
33
import pytest
4-
import pandas as pd
54
import pdfplumber
65
from subprocess import Popen, PIPE
76
from io import StringIO

tests/test_display.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
import unittest
3-
import pandas as pd
43
import pdfplumber
54
import sys, os, io
65

tests/test_issues.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
import unittest
3-
import pandas as pd
43
import pdfplumber
54
import sys, os
65
import six

tests/test_la_precinct_bulletin.py

Lines changed: 0 additions & 121 deletions
This file was deleted.

tests/test_nics_report.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
import unittest
3-
import pandas as pd
43
import pdfplumber
54
from operator import itemgetter
65
from pdfplumber.utils import within_bbox, collate_chars
@@ -86,36 +85,6 @@ def parse_row(row):
8685
month_text = collate_chars(month_chars)
8786
assert(month_text == "November - 2015")
8887

89-
def test_pandas(self):
90-
page = self.pdf.pages[0]
91-
cropped = page.crop((0, 80, self.PDF_WIDTH, 485))
92-
table = cropped.extract_table({
93-
"horizontal_strategy": "text",
94-
"explicit_vertical_lines": [
95-
min(map(itemgetter("x0"), cropped.chars))
96-
],
97-
"intersection_tolerance": 5
98-
})
99-
100-
table = pd.DataFrame(table)
101-
102-
def parse_value(x):
103-
if pd.isnull(x) or x == "": return None
104-
return int(x.replace(",", ""))
105-
106-
table.columns = COLUMNS
107-
table[table.columns[1:]] = table[table.columns[1:]].applymap(parse_value)
108-
109-
# [1:] because first column is state name
110-
for c in COLUMNS[1:]:
111-
total = table[c].iloc[-1]
112-
colsum = table[c].sum()
113-
assert(colsum == (total * 2))
114-
115-
month_chars = within_bbox(page.chars, (0, 35, self.PDF_WIDTH, 65))
116-
month_text = collate_chars(month_chars)
117-
assert(month_text == "November - 2015")
118-
11988
def test_filter(self):
12089
page = self.pdf.pages[0]
12190
def test(obj):

0 commit comments

Comments
 (0)