MCPcopy Index your code
hub / github.com/RustPython/RustPython / test__create_stdlib_context

Method test__create_stdlib_context

Lib/test/test_ssl.py:1550–1578  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1548 self._assert_context_options(ctx)
1549
1550 def test__create_stdlib_context(self):
1551 ctx = ssl._create_stdlib_context()
1552 self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
1553 self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
1554 self.assertFalse(ctx.check_hostname)
1555 self._assert_context_options(ctx)
1556
1557 if has_tls_protocol(ssl.PROTOCOL_TLSv1):
1558 with warnings_helper.check_warnings():
1559 ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)
1560 self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1)
1561 self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
1562 self._assert_context_options(ctx)
1563
1564 with warnings_helper.check_warnings():
1565 ctx = ssl._create_stdlib_context(
1566 ssl.PROTOCOL_TLSv1_2,
1567 cert_reqs=ssl.CERT_REQUIRED,
1568 check_hostname=True
1569 )
1570 self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLSv1_2)
1571 self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
1572 self.assertTrue(ctx.check_hostname)
1573 self._assert_context_options(ctx)
1574
1575 ctx = ssl._create_stdlib_context(purpose=ssl.Purpose.CLIENT_AUTH)
1576 self.assertEqual(ctx.protocol, ssl.PROTOCOL_TLS_SERVER)
1577 self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
1578 self._assert_context_options(ctx)
1579
1580 def test_check_hostname(self):
1581 with warnings_helper.check_warnings():

Callers

nothing calls this directly

Calls 5

has_tls_protocolFunction · 0.85
assertFalseMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected