MCPcopy
hub / github.com/PyMySQL/PyMySQL / test_issue_114

Method test_issue_114

pymysql/tests/test_issues.py:353–380  ·  view source on GitHub ↗

autocommit is not set after reconnecting with ping()

(self)

Source from the content-addressed store, hash-verified

351 cur.execute("DROP PROCEDURE IF EXISTS `foo`")
352
353 def test_issue_114(self):
354 """autocommit is not set after reconnecting with ping()"""
355 conn = pymysql.connect(charset="utf8", **self.databases[0])
356 conn.autocommit(False)
357 c = conn.cursor()
358 c.execute("""select @@autocommit;""")
359 self.assertFalse(c.fetchone()[0])
360 conn.close()
361 with warnings.catch_warnings():
362 warnings.filterwarnings("ignore")
363 conn.ping(reconnect=True)
364 c.execute("""select @@autocommit;""")
365 self.assertFalse(c.fetchone()[0])
366 conn.close()
367
368 # Ensure autocommit() is still working
369 conn = pymysql.connect(charset="utf8", **self.databases[0])
370 c = conn.cursor()
371 c.execute("""select @@autocommit;""")
372 self.assertFalse(c.fetchone()[0])
373 conn.close()
374 with warnings.catch_warnings():
375 warnings.filterwarnings("ignore")
376 conn.ping(reconnect=True)
377 conn.autocommit(True)
378 c.execute("""select @@autocommit;""")
379 self.assertTrue(c.fetchone()[0])
380 conn.close()
381
382 def test_issue_175(self):
383 """The number of fields returned by server is read in wrong way"""

Callers

nothing calls this directly

Calls 7

autocommitMethod · 0.80
cursorMethod · 0.80
executeMethod · 0.80
pingMethod · 0.80
connectMethod · 0.45
fetchoneMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected