-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG in clipboard (linux, python2) with unicode and separator (GH13747) #14599
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
Conversation
I believe this fix should also close #12529 (at least it worked for me a few months ago on linux and windows). Good practice is to add some tests for a fix, for example as in xref #12580 |
@pijucha , i thought we already have one unicode character test in test_clipboard.py (GH 13747) that used to fail earliers (in OSX) and it passes with this change, do i need to add more? |
Ah, you're right. I forgot. I played with some non-latin characters and also °C for the other issue - just to be sure. The existing test contains only |
@pijucha and none of the existing tests failed post this change so i think we can prolly merge it |
I ran this test case in local post changes and it succeeds df = pd.DataFrame({'a':['µasd','Ωœ∑´'], 'b':['øπ∆˚¬','œ∑´®']}) |
wouldn't hurt to add that as a test |
should i add this as a individual test in pandas/io/tests/test_clipboard.py itself? |
yep |
Current coverage is 85.20% (diff: 30.09%)@@ master #14599 diff @@
==========================================
Files 140 143 +3
Lines 50706 50773 +67
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43248 43262 +14
- Misses 7458 7511 +53
Partials 0 0
|
@jreback i have added the test case in the file |
# unicode round trip test for GH 13747 | ||
def test_round_trip_frame_unicode(self): | ||
sep = ',' | ||
df = pd.DataFrame({'a':['µasd','Ωœ∑´'], 'b':['øπ∆˚¬','œ∑´®']}) |
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.
@aileronajay
Just a thought: adding this
cls.data['utf8'] = pd.DataFrame({'a': ['µasd', 'Ωœ∑´'], 'b': ['øπ∆˚¬', 'œ∑´®']})
to the method setUpClass
above would have the same (or better) effect as the separate test but the code would be neater.
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.
@pijucha that makes sense and i thought of doing that initially, but wouldn't that make the code similar to en espanol test that is already present. Though i can make change if that seems to be the way to go :)
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.
Placing it in setUpClass
just allows to run all tests automatically. Whether it's similar to en espanol
is another thing (Chinese or cyrillic characters might be less similar but it's probably ok).
@pijucha I have refactored the test case to be in sync with the rest of the file |
that might just be a stalled build it happens in any event i would ideally like to have a test that actually fails on linux (and os x) before this change (so that once this fix is applied the test passes) iow this is not currently tested on linux (though it fails for me locally as well) |
I think we just disabled the test in the linked issue - can u re enable |
yes - ideally see if that fails w/o your change then passes with / that was out there a long time ago (so the test might not work well anyhow) |
@jreback , when i run all tests in my local machine, using the script, test.sh (at root directory), it does run these clipboard tests (that is how i came across this issue in the first place). So now i wonder if the disabled tag works at all, as the test.sh was able to call test_clipboard.py even with the disabled tag in place and now that i have removed the disabled tag, it would definitely execute the clipboard tests |
what i mean is travis doesn't run the disabled tests by default |
FYI I think they will fail on travis. In this job which is under my pytest branch, I had messed up the |
…hey pass after this change
@aileronajay ok looks like if u can get these to pass on your other PR would be great |
@jreback i have implemented the code review comments |
@jreback can you pls take a look |
https://travis-ci.org/pandas-dev/pandas/builds/176283955 some failures. |
@aileronajay changes look fine. just need to nail down testing. |
@jreback the job that had failed earlier has this log message (pasted below). I think it was due to an intermittent network issue
|
@aileronajay yes 1 job failed. however 3 of the bottom jobs failed: https://travis-ci.org/pandas-dev/pandas/builds/176283955. These must pass as well. |
@jreback the 3 jobs that have failed at the bottom, have one common error ERROR: test_round_trip_frame (pandas.io.tests.test_clipboard.TestClipboard)Traceback (most recent call last): In the latest version of pyperclip, it decides how to get the clipboard using this query def determine_clipboard():
where the HAS_DISPLAY is retrieved using HAS_DISPLAY = os.getenv("DISPLAY", False). So in a unix env if the HAS_DISPLAY resolved to false, we will get the exception that we are getting ( pandas.util.clipboard.exceptions.PyperclipException: |
ok this is easy then. we don't test this on every system. change the top portion
to something that triggers the exception (and then catch the error, so we can skip the tests if its not installed) e.g.
|
@@ -43,3 +43,4 @@ Bug Fixes | |||
|
|||
|
|||
- Explicit check in ``to_stata`` and ``StataWriter`` for out-of-range values when writing doubles (:issue:`14618`) | |||
- BUG in clipboard (linux, python2) with unicode and separator (:issue:`13747`) |
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.
list all of the isues this is expected to close
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.
implemented this change now
@@ -115,3 +119,16 @@ def test_read_clipboard_infer_excel(self): | |||
exp = pd.read_clipboard() | |||
|
|||
tm.assert_frame_equal(res, exp) | |||
|
|||
# test case for testing invalid encoding | |||
def test_invalid_encoding(self): |
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.
put comments inside the test
put the issue number as a comment
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.
implemented the suggested change
@@ -115,3 +119,16 @@ def test_read_clipboard_infer_excel(self): | |||
exp = pd.read_clipboard() |
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.
can you add tests for other issues that we mentioned (or attach the issue number to an existing tests as appropriate)
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.
@jreback after handling of the cases where clipboard primitives are absent, tests are not failing anymore. Also added additional bugs that are being fixed to whatsnew file and tagged them to tests as appropriate |
@jreback I have addressed the review comments given earlier and we dont have any failures related to this change |
thanks @aileronajay really nice effort! |
Thanks @jreback |
vendered updated version of Pyperclip closes pandas-dev#13747 closes pandas-dev#14362 closes pandas-dev#12807 closes pandas-dev#12529 Author: Ajay Saxena <[email protected]> Author: Ajay Saxena <[email protected]> Closes pandas-dev#14599 from aileronajay/master and squashes the following commits: 2aafb66 [Ajay Saxena] moved comment inside test and added github issue labels to test b74fbc1 [Ajay Saxena] ignore lint test for pyperclip files 9db42d8 [Ajay Saxena] whatsnew conflict 1dca292 [Ajay Saxena] conflict resolution 98b61e8 [Ajay Saxena] merge conflict cedb690 [Ajay Saxena] merge conflict in whats new file 7af95da [Ajay Saxena] merging lastest changes ac8ae60 [Ajay Saxena] skip clipboard test if clipboard primitives are absent b03ed56 [Ajay Saxena] changed whatsnew file c0aafd7 [Ajay Saxena] Merge branch 'test_branch' 9946fb7 [Ajay Saxena] Merge branch 'master' of https://github.com/pandas-dev/pandas into test_branch ed1375f [Ajay Saxena] Merge branch 'test_branch' 0665fd4 [Ajay Saxena] fixed linting and test case as per code review d202fd0 [Ajay Saxena] added test for valid encoding, modified setup.py so that pandas/util/clipboard can be found dd57ae3 [Ajay Saxena] code review changes and read clipboard invalid encoding test 71d58d0 [Ajay Saxena] testing encoding in kwargs to to_clipboard and test case for the same 02f87b0 [Ajay Saxena] removed duplicate files 825bbe2 [Ajay Saxena] all files related to pyperclip are under pandas.util.clipboard c5a87d8 [Ajay Saxena] Merge branch 'test_branch' of https://github.com/aileronajay/pandas into test_branch f708c2e [Ajay Saxena] Merge branch 'master' of https://github.com/aileronajay/pandas d565b1f [Ajay Saxena] updated pyperclip to the latest version 14d94a0 [Ajay Saxena] changed the pandas util clipboard file to return unicode if the python version is 2, else str 66d8ebf [Ajay Saxena] removed the disabled tag for clipboard test so that we can check if they pass after this change edb8553 [Ajay Saxena] refactored the new unicode test to be in sync with the rest of the file c83d000 [Ajay Saxena] added test case for unicode round trip fb922d6 [Ajay Saxena] changes for GH 13747 (cherry picked from commit 4a1a330)
git diff upstream/master | flake8 --diff