Skip to content

Commit 18c1c75

Browse files
committed
Bypass ioreader
1 parent ef237dd commit 18c1c75

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

pandas/io/tests/sas/test_sas7bdat.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,15 @@ def test_from_buffer(self):
4444
df0 = self.data[j]
4545
for k in self.test_ix[j]:
4646
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k)
47-
with open(fname, 'rb') as f:
48-
byts = f.read()
49-
buf = io.BytesIO(byts)
50-
df = pd.read_sas(buf, format="sas7bdat", encoding='utf-8')
47+
df = pd.read_sas(fname, encoding="utf-8")
5148
tm.assert_frame_equal(df, df0, check_exact=False)
5249

5350
def test_from_iterator(self):
5451
for j in 0, 1:
5552
df0 = self.data[j]
5653
for k in self.test_ix[j]:
5754
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k)
58-
with open(fname, 'rb') as f:
59-
byts = f.read()
60-
buf = io.BytesIO(byts)
61-
rdr = pd.read_sas(buf, format="sas7bdat",
62-
iterator=True, encoding='utf-8')
55+
rdr = pd.read_sas(fname, iterator=True, encoding='utf-8')
6356
df = rdr.read(2)
6457
tm.assert_frame_equal(df, df0.iloc[0:2, :])
6558
df = rdr.read(3)
@@ -71,11 +64,7 @@ def test_iterator_loop(self):
7164
for k in self.test_ix[j]:
7265
for chunksize in 3, 5, 10, 11:
7366
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k)
74-
with open(fname, 'rb') as f:
75-
byts = f.read()
76-
buf = io.BytesIO(byts)
77-
rdr = pd.read_sas(buf, format="sas7bdat",
78-
chunksize=chunksize, encoding='utf-8')
67+
rdr = pd.read_sas(fname, chunksize=10, encoding='utf-8')
7968
y = 0
8069
for x in rdr:
8170
y += x.shape[0]
@@ -90,7 +79,10 @@ def test_iterator_read_too_much(self):
9079
buf = io.BytesIO(byts)
9180
rdr = pd.read_sas(buf, format="sas7bdat",
9281
iterator=True, encoding='utf-8')
93-
rdr.read(rdr.row_count + 20)
82+
d1 = rdr.read(rdr.row_count + 20)
83+
rdr = pd.read_sas(fname, iterator=True, encoding="utf-8")
84+
d2 = rdr.read(rdr.row_count + 20)
85+
tm.assert_frame_equal(d1, d2)
9486

9587

9688
def test_encoding_options():

0 commit comments

Comments
 (0)