-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: windows with TemporaryFile an read_csv #13398 #13481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
d8decae
5af8465
119fb65
98e476e
fd20aaf
d8ceb57
1c33fb5
aa3f0aa
5871625
0d54151
8b52631
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,8 @@ class TestCommonIOCapabilities(tm.TestCase): | |
foo2,12,13,14,15 | ||
bar2,12,13,14,15 | ||
""" | ||
|
||
data2 = data1.replace(",", " ") | ||
|
||
def test_expand_user(self): | ||
filename = '~/sometest' | ||
expanded_name = common._expand_user(filename) | ||
|
@@ -90,6 +91,18 @@ def test_iterator(self): | |
expected.index = [0 for i in range(len(expected))] | ||
tm.assert_frame_equal(concat(it), expected.iloc[1:]) | ||
|
||
def test_temporary_file(self): | ||
# GH13398 | ||
from tempfile import TemporaryFile | ||
new_file = TemporaryFile("w+") | ||
new_file.write(self.data2) | ||
new_file.flush() | ||
new_file.seek(0) | ||
|
||
result = read_csv(new_file, sep=r"\s+", engine="python") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a corresponding test for the c engine that does the same? or is this specifically an issue with the python engine? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's specific to the Python engine as it has to do with the regex. |
||
expected = read_csv(StringIO(self.data1)) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You meqn reference the issue in the test (comment)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly: def test_temporary_file(self):
# see gh-13398
... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are those tests run? They all fail when called explicitely (and they should). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they do. If you look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the errors I get:
And they are proper issues in the test file. |
||
class TestMMapWrapper(tm.TestCase): | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your original example was fine. No need to do this here unless
data2
is intended to be used elsewhere. All you had to do was changeread_table
toread_csv
in the initial version of your test.Also, move this into
python_parser_only.py
!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to use the regular expression and make sure I'm going through the code path I modified (I need a non default sep).
Also see my current issue with the file (not run by nosetests by default?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, figured it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your original test was using regular expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! That's just to build a consistent DataFrame with two different mechanism, I'm assuming the one with StringIO + csv data will always be OK.