]> granicus.if.org Git - python/commitdiff
Issue #22165: Fixed test_undecodable_filename on non-UTF-8 locales.
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 Aug 2014 09:20:02 +0000 (12:20 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 Aug 2014 09:20:02 +0000 (12:20 +0300)
Lib/test/test_httpservers.py

index 8c22651949f12ca2ae5e6f36f1a2380d248af637..ad058b5efa4855250bb042b3e43be353b941db67 100644 (file)
@@ -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)