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

Method test_issue_114

pymysql/tests/test_issues.py:350–377  ·  view source on GitHub ↗

autocommit is not set after reconnecting with ping()

(self)

Source from the content-addressed store, hash-verified

348 cur.execute("DROP PROCEDURE IF EXISTS `foo`")
349
350 def test_issue_114(self):
351 """autocommit is not set after reconnecting with ping()"""
352 conn = pymysql.connect(charset="utf8", **self.databases[0])
353 conn.autocommit(False)
354 c = conn.cursor()
355 c.execute("""select @@autocommit;""")
356 self.assertFalse(c.fetchone()[0])
357 conn.close()
358 with warnings.catch_warnings():
359 warnings.filterwarnings("ignore")
360 conn.ping(reconnect=True)
361 c.execute("""select @@autocommit;""")
362 self.assertFalse(c.fetchone()[0])
363 conn.close()
364
365 # Ensure autocommit() is still working
366 conn = pymysql.connect(charset="utf8", **self.databases[0])
367 c = conn.cursor()
368 c.execute("""select @@autocommit;""")
369 self.assertFalse(c.fetchone()[0])
370 conn.close()
371 with warnings.catch_warnings():
372 warnings.filterwarnings("ignore")
373 conn.ping(reconnect=True)
374 conn.autocommit(True)
375 c.execute("""select @@autocommit;""")
376 self.assertTrue(c.fetchone()[0])
377 conn.close()
378
379 def test_issue_175(self):
380 """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