MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / test_connection_gone_away

Method test_connection_gone_away

pymysql/tests/test_connection.py:498–511  ·  view source on GitHub ↗

http://dev.mysql.com/doc/refman/5.0/en/gone-away.html http://dev.mysql.com/doc/refman/5.0/en/error-messages-client.html#error_cr_server_gone_error

(self)

Source from the content-addressed store, hash-verified

496 self.assertEqual(cur.fetchone()[0], other_db)
497
498 def test_connection_gone_away(self):
499 """
500 http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
501 http://dev.mysql.com/doc/refman/5.0/en/error-messages-client.html#error_cr_server_gone_error
502 """
503 con = self.connect()
504 cur = con.cursor()
505 cur.execute("SET wait_timeout=1")
506 time.sleep(2)
507 with self.assertRaises(pymysql.OperationalError) as cm:
508 cur.execute("SELECT 1+1")
509 # error occurs while reading, not writing because of socket buffer.
510 # self.assertEqual(cm.exception.args[0], 2006)
511 self.assertIn(cm.exception.args[0], (2006, 2013))
512
513 def test_init_command(self):
514 conn = self.connect(

Callers

nothing calls this directly

Calls 3

cursorMethod · 0.80
executeMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected