Commit 19f6bd06 authored by Pablo Galindo's avatar Pablo Galindo Committed by Victor Stinner

bpo-33354: Fix test_ssl when a filename cannot be encoded (GH-6613)

Skip test_load_dh_params() of test_ssl when Python filesystem encoding
cannot encode the provided path.
parent 9044cd67
......@@ -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)
......
Skip ``test_ssl.test_load_dh_params`` when Python filesystem encoding cannot encode the
provided path.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment