@@ -1660,14 +1660,17 @@ def test_pathname2url_nonascii(self):
16601660 url = urllib .parse .quote (os_helper .FS_NONASCII , encoding = encoding , errors = errors )
16611661 self .assertEqual (urllib .request .pathname2url (os_helper .FS_NONASCII ), url )
16621662
1663+ @unittest .skipUnless (os_helper .TESTFN_UNDECODABLE ,
1664+ 'need os_helper.TESTFN_UNDECODABLE' )
16631665 def test_pathname2url_surrogates (self ):
16641666 # gh-156713: the filesystem encoding and error handler are used,
16651667 # so that paths containing surrogate characters can be converted.
16661668 encoding = sys .getfilesystemencoding ()
16671669 errors = sys .getfilesystemencodeerrors ()
1668- tail = urllib .parse .quote ('a\udcff ' , encoding = encoding , errors = errors )
1669- self .assertEqual (nturl2path .pathname2url ('C:\\ a\udcff ' ),
1670- '///C:/' + tail )
1670+ path = os .fsdecode (os_helper .TESTFN_UNDECODABLE )
1671+ url = urllib .parse .quote (path , encoding = encoding , errors = errors )
1672+ self .assertEqual (nturl2path .pathname2url ('C:\\ ' + path ),
1673+ '///C:/' + url )
16711674
16721675 @unittest .skipUnless (sys .platform == 'win32' ,
16731676 'test specific to Windows pathnames.' )
@@ -1730,14 +1733,17 @@ def test_url2pathname_nonascii(self):
17301733 url = urllib .parse .quote (url , encoding = encoding , errors = errors )
17311734 self .assertEqual (urllib .request .url2pathname (url ), os_helper .FS_NONASCII )
17321735
1736+ @unittest .skipUnless (os_helper .TESTFN_UNDECODABLE ,
1737+ 'need os_helper.TESTFN_UNDECODABLE' )
17331738 def test_url2pathname_surrogates (self ):
17341739 # gh-156713: the filesystem encoding and error handler are used, so
17351740 # that URLs containing percent-encoded surrogates can be converted.
17361741 encoding = sys .getfilesystemencoding ()
17371742 errors = sys .getfilesystemencodeerrors ()
1738- url = urllib .parse .quote ('a\udcff ' , encoding = encoding , errors = errors )
1743+ path = os .fsdecode (os_helper .TESTFN_UNDECODABLE )
1744+ url = urllib .parse .quote (path , encoding = encoding , errors = errors )
17391745 self .assertEqual (nturl2path .url2pathname ('///C:/' + url ),
1740- 'C:\\ a \udcff ' )
1746+ 'C:\\ ' + path )
17411747
17421748class Utility_Tests (unittest .TestCase ):
17431749 """Testcase to test the various utility functions in the urllib."""
0 commit comments