mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.
This commit is contained in:
parent
cb5bc408ad
commit
a64ce5d744
1 changed files with 3 additions and 2 deletions
|
@ -272,6 +272,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
||||||
@unittest.skipUnless(support.TESTFN_UNDECODABLE,
|
@unittest.skipUnless(support.TESTFN_UNDECODABLE,
|
||||||
'need support.TESTFN_UNDECODABLE')
|
'need support.TESTFN_UNDECODABLE')
|
||||||
def test_undecodable_filename(self):
|
def test_undecodable_filename(self):
|
||||||
|
enc = sys.getfilesystemencoding()
|
||||||
filename = os.fsdecode(support.TESTFN_UNDECODABLE) + '.txt'
|
filename = os.fsdecode(support.TESTFN_UNDECODABLE) + '.txt'
|
||||||
with open(os.path.join(self.tempdir, filename), 'wb') as f:
|
with open(os.path.join(self.tempdir, filename), 'wb') as f:
|
||||||
f.write(support.TESTFN_UNDECODABLE)
|
f.write(support.TESTFN_UNDECODABLE)
|
||||||
|
@ -279,9 +280,9 @@ class SimpleHTTPServerTestCase(BaseTestCase):
|
||||||
body = self.check_status_and_reason(response, 200)
|
body = self.check_status_and_reason(response, 200)
|
||||||
quotedname = urllib.parse.quote(filename, errors='surrogatepass')
|
quotedname = urllib.parse.quote(filename, errors='surrogatepass')
|
||||||
self.assertIn(('href="%s"' % quotedname)
|
self.assertIn(('href="%s"' % quotedname)
|
||||||
.encode('utf-8', 'surrogateescape'), body)
|
.encode(enc, 'surrogateescape'), body)
|
||||||
self.assertIn(('>%s<' % html.escape(filename))
|
self.assertIn(('>%s<' % html.escape(filename))
|
||||||
.encode('utf-8', 'surrogateescape'), body)
|
.encode(enc, 'surrogateescape'), body)
|
||||||
response = self.request(self.tempdir_name + '/' + quotedname)
|
response = self.request(self.tempdir_name + '/' + quotedname)
|
||||||
self.check_status_and_reason(response, 200,
|
self.check_status_and_reason(response, 200,
|
||||||
data=support.TESTFN_UNDECODABLE)
|
data=support.TESTFN_UNDECODABLE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue