Skip to content

Commit 240383c

Browse files
committed
Properly close opened files in two tests
1 parent 52d1073 commit 240383c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pandas/io/tests/sas/test_sas7bdat.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ 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-
byts = open(fname, 'rb').read()
47+
with open(fname, 'rb') as f:
48+
byts = f.read()
4849
buf = io.BytesIO(byts)
4950
df = pd.read_sas(buf, format="sas7bdat", encoding='utf-8')
5051
tm.assert_frame_equal(df, df0, check_exact=False)
@@ -54,7 +55,8 @@ def test_from_iterator(self):
5455
df0 = self.data[j]
5556
for k in self.test_ix[j]:
5657
fname = os.path.join(self.dirpath, "test%d.sas7bdat" % k)
57-
byts = open(fname, 'rb').read()
58+
with open(fname, 'rb') as f:
59+
byts = f.read()
5860
buf = io.BytesIO(byts)
5961
rdr = pd.read_sas(buf, format="sas7bdat",
6062
iterator=True, encoding='utf-8')

0 commit comments

Comments
 (0)