summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-08-17 09:21:06 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-08-17 09:21:06 (GMT)
commitfbe912b7566f90835e968dbd01c2fa726ece6120 (patch)
treec6464547a3e387ec8e04aa48fad56a60b5d714bc
parent41a08e557a7b12277f98e180986d3bf06b07f7ea (diff)
parenta64ce5d7446f226805ff27d99dcecbc8681733d8 (diff)
downloadcpython-fbe912b7566f90835e968dbd01c2fa726ece6120.zip
cpython-fbe912b7566f90835e968dbd01c2fa726ece6120.tar.gz
cpython-fbe912b7566f90835e968dbd01c2fa726ece6120.tar.bz2
Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.
-rw-r--r--Lib/test/test_httpservers.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 8c22651..ad058b5 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -272,6 +272,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
@unittest.skipUnless(support.TESTFN_UNDECODABLE,
'need support.TESTFN_UNDECODABLE')
def test_undecodable_filename(self):
+ enc = sys.getfilesystemencoding()
filename = os.fsdecode(support.TESTFN_UNDECODABLE) + '.txt'
with open(os.path.join(self.tempdir, filename), 'wb') as f:
f.write(support.TESTFN_UNDECODABLE)
@@ -279,9 +280,9 @@ class SimpleHTTPServerTestCase(BaseTestCase):
body = self.check_status_and_reason(response, 200)
quotedname = urllib.parse.quote(filename, errors='surrogatepass')
self.assertIn(('href="%s"' % quotedname)
- .encode('utf-8', 'surrogateescape'), body)
+ .encode(enc, 'surrogateescape'), body)
self.assertIn(('>%s<' % html.escape(filename))
- .encode('utf-8', 'surrogateescape'), body)
+ .encode(enc, 'surrogateescape'), body)
response = self.request(self.tempdir_name + '/' + quotedname)
self.check_status_and_reason(response, 200,
data=support.TESTFN_UNDECODABLE)