def test_set_tlsext_host_name_wrong_args(self):
"""
If L{Connection.set_tlsext_host_name} is called with a non-byte string
argument or a byte string with an embedded NUL or other than one
argument, L{TypeError} is raised.
"""
conn = Connection(Context(TLSv1_METHOD), None)
self.assertRaises(TypeError, conn.set_tlsext_host_name)
self.assertRaises(TypeError, conn.set_tlsext_host_name, object())
self.assertRaises(TypeError, conn.set_tlsext_host_name, 123, 456)
self.assertRaises(
TypeError, conn.set_tlsext_host_name, b("with\0null"))
if version_info >= (3,):
# On Python 3.x, don't accidentally implicitly convert from text.
self.assertRaises(
TypeError,
conn.set_tlsext_host_name, b("example.com").decode("ascii"))
评论列表
文章目录