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

Method test_socketserver

Lib/test/test_ssl.py:3784–3808  ·  view source on GitHub ↗

Using socketserver to create and manage SSL connections.

(self)

Source from the content-addressed store, hash-verified

3782 s.close()
3783
3784 def test_socketserver(self):
3785 """Using socketserver to create and manage SSL connections."""
3786 server = make_https_server(self, certfile=SIGNED_CERTFILE)
3787 # try to connect
3788 if support.verbose:
3789 sys.stdout.write('\n')
3790 # Get this test file itself:
3791 with open(__file__, 'rb') as f:
3792 d1 = f.read()
3793 d2 = ''
3794 # now fetch the same data from the HTTPS server
3795 url = f'https://localhost:{server.port}/test_ssl.py'
3796 context = ssl.create_default_context(cafile=SIGNING_CA)
3797 f = urllib.request.urlopen(url, context=context)
3798 try:
3799 dlen = f.info().get("content-length")
3800 if dlen and (int(dlen) > 0):
3801 d2 = f.read(int(dlen))
3802 if support.verbose:
3803 sys.stdout.write(
3804 " client: read %d bytes from remote server '%s'\n"
3805 % (len(d2), server))
3806 finally:
3807 f.close()
3808 self.assertEqual(d1, d2)
3809
3810 def test_asyncore_server(self):
3811 """Check the example asyncore integration."""

Callers

nothing calls this directly

Calls 9

make_https_serverFunction · 0.90
openFunction · 0.50
writeMethod · 0.45
readMethod · 0.45
urlopenMethod · 0.45
getMethod · 0.45
infoMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected