[Python-checkins] cpython (merge 3.4 -> default): Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.

serhiy.storchaka python-checkins at python.org
Sun Aug 17 11:22:51 CEST 2014


http://hg.python.org/cpython/rev/7cdc941d5180
changeset:   92128:7cdc941d5180
parent:      92126:3153a400b739
parent:      92127:a894b629bbea
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Sun Aug 17 12:21:06 2014 +0300
summary:
  Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.

files:
  Lib/test/test_httpservers.py |  5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -272,6 +272,7 @@
     @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 @@
         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)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list