Skip to content

Commit 73510b6

Browse files
add file/mmap test cases
1 parent ecaef69 commit 73510b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/io/tests/parser/common.py

+17
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,23 @@ def test_internal_eof_byte(self):
16051605

16061606
def test_file_handles(self):
16071607
# GH 14418 - don't close user provided file handles
1608+
16081609
fh = StringIO('a,b\n1,2')
16091610
self.read_csv(fh)
16101611
self.assertFalse(fh.closed)
1612+
1613+
with open(self.csv1, 'r') as f:
1614+
self.read_csv(f)
1615+
self.assertFalse(f.closed)
1616+
1617+
# mmap not working with python engine
1618+
if self.engine != 'python':
1619+
1620+
import mmap
1621+
with open(self.csv1, 'r') as f:
1622+
m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
1623+
self.read_csv(m)
1624+
# closed attribute new in python 3.2
1625+
if PY3:
1626+
self.assertFalse(m.closed)
1627+
m.close()

0 commit comments

Comments
 (0)