Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r96984:4e0d2e9d1e7d
Date: 2019-07-14 08:11 +0000
http://bitbucket.org/pypy/pypy/changeset/4e0d2e9d1e7d/
Log: Merged in ivan257/pypy/fix_darwin_list_dir_test (pull request #653)
Fix test_list_dir_unicode on macOS utf-8 encoded systems
diff --git a/pypy/module/posix/test/test_posix2.py
b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -372,15 +372,24 @@
result = posix.listdir(unicode_dir)
typed_result = [(type(x), x) for x in result]
assert (unicode, u'somefile') in typed_result
+ file_system_encoding = sys.getfilesystemencoding()
try:
- u = "caf\xe9".decode(sys.getfilesystemencoding())
+ u = "caf\xe9".decode(file_system_encoding)
except UnicodeDecodeError:
# Could not decode, listdir returned the byte string
if sys.platform != 'darwin':
assert (str, "caf\xe9") in typed_result
else:
- # darwin 'normalized' it
- assert (unicode, 'caf%E9') in typed_result
+ # if the test is being run in an utf-8 encoded macOS
+ # the posix.listdir function is returning the name of
+ # the file properly.
+ # This test should be run in multiple macOS platforms to
+ # be sure that is working as expected.
+ if file_system_encoding == 'UTF-8':
+ assert (unicode, 'cafxe9') in typed_result
+ else:
+ # darwin 'normalized' it
+ assert (unicode, 'caf%E9') in typed_result
else:
assert (unicode, u) in typed_result
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit