MCPcopy
hub / github.com/PyMySQL/PyMySQL / test_defer_connect

Method test_defer_connect

pymysql/tests/test_connection.py:536–558  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

534 # TODO validate setting here
535
536 def test_defer_connect(self):
537 import socket
538
539 d = self.databases[0].copy()
540 try:
541 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
542 sock.connect(d["unix_socket"])
543 except KeyError:
544 sock.close()
545 sock = socket.create_connection(
546 (d.get("host", "localhost"), d.get("port", 3306))
547 )
548 for k in ["unix_socket", "host", "port"]:
549 try:
550 del d[k]
551 except KeyError:
552 pass
553
554 c = pymysql.connect(defer_connect=True, **d)
555 self.assertFalse(c.open)
556 c.connect(sock)
557 c.close()
558 sock.close()
559
560 def test_ssl_connect(self):
561 dummy_ssl_context = mock.Mock(options=0, verify_flags=0)

Callers

nothing calls this directly

Calls 3

getMethod · 0.80
connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected