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

Method test_https_client

Lib/test/test_httpservers.py:1543–1560  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1541
1542 @unittest.skipIf(ssl is None, "requires ssl")
1543 def test_https_client(self):
1544 context = ssl.create_default_context()
1545 # allow self-signed certificates
1546 context.check_hostname = False
1547 context.verify_mode = ssl.CERT_NONE
1548
1549 bind, port = '127.0.0.1', find_unused_port()
1550 proc = spawn_python('-u', '-m', 'http.server', str(port), '-b', bind,
1551 '--tls-cert', self.tls_cert,
1552 '--tls-key', self.tls_key,
1553 '--tls-password-file', self.tls_password_file,
1554 bufsize=1, text=True)
1555 self.addCleanup(kill_python, proc)
1556 self.addCleanup(proc.terminate)
1557 self.assertTrue(self.wait_for_server(proc, 'https', bind, port))
1558 url = f'https://{bind}:{port}/{self.served_filename}'
1559 res = self.fetch_file(url, context=context)
1560 self.assertEqual(res, self.served_data)
1561
1562
1563class TestModule(unittest.TestCase):

Callers

nothing calls this directly

Calls 8

wait_for_serverMethod · 0.95
fetch_fileMethod · 0.95
find_unused_portFunction · 0.90
spawn_pythonFunction · 0.90
strFunction · 0.85
addCleanupMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected