bpo-27200: fix pathlib, ssl, turtle and weakref doctests by marco-buttu · Pull Request #616 · python/cpython
.. testsetup::
import ssl
.. function:: match_hostname(cert, hostname)
Verify that *cert* (in decoded format as returned by
>>> import ssl >>> timestamp = ssl.cert_time_to_seconds("Jan 5 09:34:43 2018 GMT") >>> timestamp >>> timestamp # doctest: +SKIP 1515144883 >>> from datetime import datetime >>> print(datetime.utcfromtimestamp(timestamp)) >>> print(datetime.utcfromtimestamp(timestamp)) # doctest: +SKIP 2018-01-05 09:34:43
"notBefore" or "notAfter" dates must use GMT (:rfc:`5280`).
On OpenSSL 1.1 and newer the cipher dict contains additional fields::
>>> ctx.get_ciphers() # OpenSSL 1.1+ [{'aead': True, 'alg_bits': 256,
>>> ssl.create_default_context().options >>> ssl.create_default_context().options # doctest: +SKIP <Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_NO_COMPRESSION: 2197947391>
.. attribute:: SSLContext.protocol
>>> ssl.create_default_context().verify_flags >>> ssl.create_default_context().verify_flags # doctest: +SKIP <VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768>
.. attribute:: SSLContext.verify_mode
::
>>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) >>> client_context.options |= ssl.OP_NO_TLSv1 >>> client_context.options |= ssl.OP_NO_TLSv1_1