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)
| 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( |