mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
[3.13] gh-133677: Fix tests when running in non-UTF-8 locale (GH-133865) (GH-133939)
(cherry picked from commit 14305a83d3
)
This commit is contained in:
parent
5ce47b96b0
commit
d9d8e9a00c
3 changed files with 10 additions and 6 deletions
|
@ -17,7 +17,7 @@ from test.support import import_helper
|
|||
from test.support import is_emscripten, is_wasi
|
||||
from test.support import infinite_recursion
|
||||
from test.support import os_helper
|
||||
from test.support.os_helper import TESTFN, FakePath
|
||||
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
|
||||
from test.test_pathlib import test_pathlib_abc
|
||||
from test.test_pathlib.test_pathlib_abc import needs_posix, needs_windows, needs_symlinks
|
||||
|
||||
|
@ -479,12 +479,16 @@ class PurePathTest(test_pathlib_abc.DummyPurePathTest):
|
|||
self.assertEqual(P('c:/').as_uri(), 'file:///c:/')
|
||||
self.assertEqual(P('c:/a/b.c').as_uri(), 'file:///c:/a/b.c')
|
||||
self.assertEqual(P('c:/a/b%#c').as_uri(), 'file:///c:/a/b%25%23c')
|
||||
self.assertEqual(P('c:/a/b\xe9').as_uri(), 'file:///c:/a/b%C3%A9')
|
||||
self.assertEqual(P('//some/share/').as_uri(), 'file://some/share/')
|
||||
self.assertEqual(P('//some/share/a/b.c').as_uri(),
|
||||
'file://some/share/a/b.c')
|
||||
self.assertEqual(P('//some/share/a/b%#c\xe9').as_uri(),
|
||||
'file://some/share/a/b%25%23c%C3%A9')
|
||||
|
||||
from urllib.parse import quote_from_bytes
|
||||
QUOTED_FS_NONASCII = quote_from_bytes(os.fsencode(FS_NONASCII))
|
||||
self.assertEqual(P('c:/a/b' + FS_NONASCII).as_uri(),
|
||||
'file:///c:/a/b' + QUOTED_FS_NONASCII)
|
||||
self.assertEqual(P('//some/share/a/b%#c' + FS_NONASCII).as_uri(),
|
||||
'file://some/share/a/b%25%23c' + QUOTED_FS_NONASCII)
|
||||
|
||||
@needs_windows
|
||||
def test_ordering_windows(self):
|
||||
|
|
|
@ -157,7 +157,7 @@ class urlopen_FileTests(unittest.TestCase):
|
|||
finally:
|
||||
f.close()
|
||||
self.pathname = os_helper.TESTFN
|
||||
self.quoted_pathname = urllib.parse.quote(self.pathname)
|
||||
self.quoted_pathname = urllib.parse.quote(os.fsencode(self.pathname))
|
||||
self.returned_obj = urlopen("file:%s" % self.quoted_pathname)
|
||||
|
||||
def tearDown(self):
|
||||
|
|
|
@ -3489,7 +3489,7 @@ class EncodedMetadataTests(unittest.TestCase):
|
|||
except OSError:
|
||||
pass
|
||||
except UnicodeEncodeError:
|
||||
self.skipTest(f'cannot encode file name {fn!r}')
|
||||
self.skipTest(f'cannot encode file name {fn!a}')
|
||||
|
||||
zipfile.main(["--metadata-encoding=shift_jis", "-e", TESTFN, TESTFN2])
|
||||
listing = os.listdir(TESTFN2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue