MCPcopy Index your code
hub / github.com/python/cpython / test_context

Method test_context

Lib/test/test_ftplib.py:984–1006  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

982 self.assertRaises(ValueError, self.client.auth)
983
984 def test_context(self):
985 self.client.quit()
986 ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
987 ctx.check_hostname = False
988 ctx.verify_mode = ssl.CERT_NONE
989 self.assertRaises(TypeError, ftplib.FTP_TLS, keyfile=CERTFILE,
990 context=ctx)
991 self.assertRaises(TypeError, ftplib.FTP_TLS, certfile=CERTFILE,
992 context=ctx)
993 self.assertRaises(TypeError, ftplib.FTP_TLS, certfile=CERTFILE,
994 keyfile=CERTFILE, context=ctx)
995
996 self.client = ftplib.FTP_TLS(context=ctx, timeout=TIMEOUT)
997 self.client.connect(self.server.host, self.server.port)
998 self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
999 self.client.auth()
1000 self.assertIs(self.client.sock.context, ctx)
1001 self.assertIsInstance(self.client.sock, ssl.SSLSocket)
1002
1003 self.client.prot_p()
1004 with self.client.transfercmd('list') as sock:
1005 self.assertIs(sock.context, ctx)
1006 self.assertIsInstance(sock, ssl.SSLSocket)
1007
1008 def test_ccc(self):
1009 self.assertRaises(ValueError, self.client.ccc)

Callers

nothing calls this directly

Calls 9

assertNotIsInstanceMethod · 0.80
assertIsInstanceMethod · 0.80
prot_pMethod · 0.80
transfercmdMethod · 0.80
quitMethod · 0.45
assertRaisesMethod · 0.45
connectMethod · 0.45
authMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected