Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d9d8e9a

Browse filesBrowse files
[3.13] gh-133677: Fix tests when running in non-UTF-8 locale (GH-133865) (GH-133939)
(cherry picked from commit 14305a8)
1 parent 5ce47b9 commit d9d8e9a
Copy full SHA for d9d8e9a

File tree

3 files changed

+10
-6
lines changed
Filter options

3 files changed

+10
-6
lines changed

‎Lib/test/test_pathlib/test_pathlib.py

Copy file name to clipboardExpand all lines: Lib/test/test_pathlib/test_pathlib.py
+8-4Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from test.support import is_emscripten, is_wasi
1818
from test.support import infinite_recursion
1919
from test.support import os_helper
20-
from test.support.os_helper import TESTFN, FakePath
20+
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
2121
from test.test_pathlib import test_pathlib_abc
2222
from test.test_pathlib.test_pathlib_abc import needs_posix, needs_windows, needs_symlinks
2323

@@ -479,12 +479,16 @@ def test_as_uri_windows(self):
479479
self.assertEqual(P('c:/').as_uri(), 'file:///c:/')
480480
self.assertEqual(P('c:/a/b.c').as_uri(), 'file:///c:/a/b.c')
481481
self.assertEqual(P('c:/a/b%#c').as_uri(), 'file:///c:/a/b%25%23c')
482-
self.assertEqual(P('c:/a/b\xe9').as_uri(), 'file:///c:/a/b%C3%A9')
483482
self.assertEqual(P('//some/share/').as_uri(), 'file://some/share/')
484483
self.assertEqual(P('//some/share/a/b.c').as_uri(),
485484
'file://some/share/a/b.c')
486-
self.assertEqual(P('//some/share/a/b%#c\xe9').as_uri(),
487-
'file://some/share/a/b%25%23c%C3%A9')
485+
486+
from urllib.parse import quote_from_bytes
487+
QUOTED_FS_NONASCII = quote_from_bytes(os.fsencode(FS_NONASCII))
488+
self.assertEqual(P('c:/a/b' + FS_NONASCII).as_uri(),
489+
'file:///c:/a/b' + QUOTED_FS_NONASCII)
490+
self.assertEqual(P('//some/share/a/b%#c' + FS_NONASCII).as_uri(),
491+
'file://some/share/a/b%25%23c' + QUOTED_FS_NONASCII)
488492

489493
@needs_windows
490494
def test_ordering_windows(self):

‎Lib/test/test_urllib.py

Copy file name to clipboardExpand all lines: Lib/test/test_urllib.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def setUp(self):
157157
finally:
158158
f.close()
159159
self.pathname = os_helper.TESTFN
160-
self.quoted_pathname = urllib.parse.quote(self.pathname)
160+
self.quoted_pathname = urllib.parse.quote(os.fsencode(self.pathname))
161161
self.returned_obj = urlopen("file:%s" % self.quoted_pathname)
162162

163163
def tearDown(self):

‎Lib/test/test_zipfile/test_core.py

Copy file name to clipboardExpand all lines: Lib/test/test_zipfile/test_core.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3489,7 +3489,7 @@ def test_cli_with_metadata_encoding_extract(self):
34893489
except OSError:
34903490
pass
34913491
except UnicodeEncodeError:
3492-
self.skipTest(f'cannot encode file name {fn!r}')
3492+
self.skipTest(f'cannot encode file name {fn!a}')
34933493

34943494
zipfile.main(["--metadata-encoding=shift_jis", "-e", TESTFN, TESTFN2])
34953495
listing = os.listdir(TESTFN2)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.