-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
I forgot to make it py3 compatible |
# When python2 | ||
assert isinstance(e, UnicodeDecodeError) | ||
|
||
unicode_base_path = base_path.decode('utf-8') |
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.
So the final question, should we force always to be str
on the find_one
method or we should document that anyone calling this function must pass a str
object and not an unicode
?
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.
Also probably would be better to explicitly check the python version on the test, right?
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.
We need to be able to support UTF8 file names, so I think we just need to patch the walk method. We did this somewhere -- either readthedocs.org or sphinx-autoapi (i think)
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.
You can also look to some of the tests that probably already mock out the find_one
calls. You shouldn't need to depend on a local repo file for the test, though this isn't a huge problem.
assert path == '' | ||
except Exception as e: | ||
# When python2 | ||
assert isinstance(e, UnicodeDecodeError) |
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.
Instead of a try/except here, I'd use six or basic python version_info checking to test for these two cases:
sys.version_info < (3,0,0)
@@ -75,3 +75,18 @@ def test_find_multiple_files(tmpdir): | |||
str(tmpdir.join('first', 'readthedocs.yml')), | |||
str(tmpdir.join('third', 'readthedocs.yml')), | |||
] | |||
|
|||
|
|||
def test_find_unicode_path(tmpdir): |
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.
This test can also be written to fail, using the pytest.xfail
decorator. Instead of writing a test that will fail once we have the bug fixed, we can write a passing case. Our tests will technically pass, but there will be an expected failure on the test run.
# When python2 | ||
assert isinstance(e, UnicodeDecodeError) | ||
|
||
unicode_base_path = base_path.decode('utf-8') |
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.
We need to be able to support UTF8 file names, so I think we just need to patch the walk method. We did this somewhere -- either readthedocs.org or sphinx-autoapi (i think)
- Run only on python2 - Mark as fail
e9252e9
to
2d0b0e5
Compare
I tried to use I think probably this is due a bad encoding or a corrupted file from the user? Even on my OS the file isn't show correctly. |
So you probably aren't able to reproduce this easily as your encoding is not
That is bad, and in fact, I'm not sure why that's happening, as our locale is set:
What you're testing might not be the right thing to test. Also, you are having trouble creating a file or path with this codepoint because your encoding is likely 'utf-8' already. With the encoding
To make this more confusing, however, even with this I'm not able to reproduce the problem with
So, I'm pretty confused at this point. |
I got the same on my local instance >>> import sys
>>> sys.getdefaultencoding()
'ascii' I asked to the user for more information readthedocs/readthedocs.org#3732 (comment), and I think probably that file was generated with some weird encoding that only Windows understand (I have seen some Windows files showing as invalid encode on my machine a couple of times). Also now that I remember, a couple of weeks ago I was helping to a German friend to setup his rtd instance and he was using Windows, and faced some similar problems with encoding (but on other part of the build). |
The fix for python encoding being crazy is "use python3". I've tried to fix the server encodings a million times, and it doesn't work. We just need to move to an all UTF-8 world. |
Looks like a good test to have, so going to merge this. |
Test to expose fix for #27
This test was a little hard to figure out how to do it, since I wasn't able to use the name on the
py
file, so I had to add an actual file (I take the file from readthedocs/readthedocs.org#3732 (comment)) and I had to made it py2 and py3 compatible. Please let me know if there is a better way.