]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-33354: Fix test_ssl when a filename cannot be encoded (GH-6613)
authorPablo Galindo <Pablogsal@gmail.com>
Thu, 24 May 2018 22:20:44 +0000 (23:20 +0100)
committerVictor Stinner <vstinner@redhat.com>
Thu, 24 May 2018 22:20:44 +0000 (00:20 +0200)
Skip test_load_dh_params() of test_ssl when Python filesystem encoding
cannot encode the provided path.

Lib/test/test_ssl.py
Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst [new file with mode: 0644]

index b59fe73f04c7a0f77b7105d111493e689d4ffca2..7ced90fdf67852dbe3229b5ab2f43c6635c87a70 100644 (file)
@@ -989,6 +989,13 @@ class ContextTests(unittest.TestCase):
 
 
     def test_load_dh_params(self):
+        filename = u'dhpäräm.pem'
+        fs_encoding = sys.getfilesystemencoding()
+        try:
+            filename.encode(fs_encoding)
+        except UnicodeEncodeError:
+            self.skipTest("filename %r cannot be encoded to the filesystem encoding %r" % (filename, fs_encoding))
+
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         ctx.load_dh_params(DHFILE)
         if os.name != 'nt':
@@ -1001,7 +1008,7 @@ class ContextTests(unittest.TestCase):
         with self.assertRaises(ssl.SSLError) as cm:
             ctx.load_dh_params(CERTFILE)
         with support.temp_dir() as d:
-            fname = os.path.join(d, u'dhpäräm.pem')
+            fname = os.path.join(d, filename)
             shutil.copy(DHFILE, fname)
             ctx.load_dh_params(fname)
 
diff --git a/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst b/Misc/NEWS.d/next/Tests/2018-04-26-22-39-17.bpo-33354.g35-44.rst
new file mode 100644 (file)
index 0000000..c66ceca
--- /dev/null
@@ -0,0 +1,2 @@
+Skip ``test_ssl.test_load_dh_params`` when Python filesystem encoding cannot encode the
+provided path.