Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit842076d

Browse files
gh-133677: Fix tests when running in non-UTF-8 locale
1 parent70f9b3d commit842076d

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

‎Lib/test/support/strace_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def events(self):
3838
3939
This assumes the program under inspection doesn't print any non-utf8
4040
strings which would mix into the strace output."""
41-
decoded_events=self.event_bytes.decode('utf-8')
41+
decoded_events=self.event_bytes.decode('utf-8','surrogateescape')
4242
matches= [
4343
_syscall_regex.match(event)
4444
foreventindecoded_events.splitlines()

‎Lib/test/test_argparse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6972,8 +6972,8 @@ def make_zip_script(self, script_name, name_in_zip=None):
69726972
returnzip_name
69736973

69746974
defcheck_usage(self,expected,*args,**kwargs):
6975-
res=script_helper.assert_python_ok('-Xutf8',*args,'-h',**kwargs)
6976-
self.assertEqual(res.out.splitlines()[0].decode(),
6975+
res=script_helper.assert_python_ok(*args,'-h',**kwargs)
6976+
self.assertEqual(os.fsdecode(res.out.splitlines()[0]),
69776977
f'usage:{expected} [-h]')
69786978

69796979
deftest_script(self,compiled=False):

‎Lib/test/test_asyncio/test_tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,21 +791,21 @@ def test_table_output_format(self):
791791
classTestAsyncioToolsEdgeCases(unittest.TestCase):
792792

793793
deftest_task_awaits_self(self):
794-
"""A task directly awaits itself should raise a cycle."""
794+
"""A task directly awaits itself- should raise a cycle."""
795795
input_= [(1, [(1,"Self-Awaiter", [[["loopback"],1]])])]
796796
withself.assertRaises(tools.CycleFoundException)asctx:
797797
tools.build_async_tree(input_)
798798
self.assertIn([1,1],ctx.exception.cycles)
799799

800800
deftest_task_with_missing_awaiter_id(self):
801-
"""Awaiter ID not in task list should not crash, just show 'Unknown'."""
801+
"""Awaiter ID not in task list- should not crash, just show 'Unknown'."""
802802
input_= [(1, [(1,"Task-A", [[["coro"],999]])])]# 999 not defined
803803
table=tools.build_task_table(input_)
804804
self.assertEqual(len(table),1)
805805
self.assertEqual(table[0][4],"Unknown")
806806

807807
deftest_duplicate_coroutine_frames(self):
808-
"""Same coroutine frame repeated under a parent should deduplicate."""
808+
"""Same coroutine frame repeated under a parent- should deduplicate."""
809809
input_= [
810810
(
811811
1,
@@ -829,7 +829,7 @@ def test_duplicate_coroutine_frames(self):
829829
self.assertIn("Task-1",flat)
830830

831831
deftest_task_with_no_name(self):
832-
"""Task with no name in id2name should still render with fallback."""
832+
"""Task with no name in id2name- should still render with fallback."""
833833
input_= [(1, [(1,"root", [[["f1"],2]]), (2,None, [])])]
834834
# If name is None, fallback to string should not crash
835835
tree=tools.build_async_tree(input_)

‎Lib/test/test_pathlib/test_pathlib.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
fromtest.supportimportis_emscripten,is_wasi
2121
fromtest.supportimportinfinite_recursion
2222
fromtest.supportimportos_helper
23-
fromtest.support.os_helperimportTESTFN,FakePath
23+
fromtest.support.os_helperimportTESTFN,FS_NONASCII,FakePath
2424
try:
2525
importfcntl
2626
exceptImportError:
@@ -770,12 +770,16 @@ def test_as_uri_windows(self):
770770
self.assertEqual(self.make_uri(P('c:/')),'file:///c:/')
771771
self.assertEqual(self.make_uri(P('c:/a/b.c')),'file:///c:/a/b.c')
772772
self.assertEqual(self.make_uri(P('c:/a/b%#c')),'file:///c:/a/b%25%23c')
773-
self.assertEqual(self.make_uri(P('c:/a/b\xe9')),'file:///c:/a/b%C3%A9')
774773
self.assertEqual(self.make_uri(P('//some/share/')),'file://some/share/')
775774
self.assertEqual(self.make_uri(P('//some/share/a/b.c')),
776775
'file://some/share/a/b.c')
777-
self.assertEqual(self.make_uri(P('//some/share/a/b%#c\xe9')),
778-
'file://some/share/a/b%25%23c%C3%A9')
776+
777+
fromurllib.parseimportquote_from_bytes
778+
QUOTED_FS_NONASCII=quote_from_bytes(os.fsencode(FS_NONASCII))
779+
self.assertEqual(self.make_uri(P('c:/a/b'+FS_NONASCII)),
780+
'file:///c:/a/b'+QUOTED_FS_NONASCII)
781+
self.assertEqual(self.make_uri(P('//some/share/a/b%#c'+FS_NONASCII)),
782+
'file://some/share/a/b%25%23c'+QUOTED_FS_NONASCII)
779783

780784
@needs_windows
781785
deftest_ordering_windows(self):

‎Lib/test/test_urllib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def setUp(self):
109109
finally:
110110
f.close()
111111
self.pathname=os_helper.TESTFN
112-
self.quoted_pathname=urllib.parse.quote(self.pathname)
112+
self.quoted_pathname=urllib.parse.quote(os.fsencode(self.pathname))
113113
self.returned_obj=urllib.request.urlopen("file:%s"%self.quoted_pathname)
114114

115115
deftearDown(self):

‎Lib/test/test_zipfile/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3642,7 +3642,7 @@ def test_cli_with_metadata_encoding_extract(self):
36423642
exceptOSError:
36433643
pass
36443644
exceptUnicodeEncodeError:
3645-
self.skipTest(f'cannot encode file name{fn!r}')
3645+
self.skipTest(f'cannot encode file name{fn!a}')
36463646

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp