MCPcopy Create free account
hub / github.com/PyMySQL/mysqlclient / test_MySQLdb

Class test_MySQLdb

tests/test_MySQLdb_dbapi20.py:11–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class test_MySQLdb(dbapi20.DatabaseAPI20Test):
12 driver = MySQLdb
13 connect_args = ()
14 connect_kw_args = connection_kwargs(
15 dict(sql_mode="ANSI,STRICT_TRANS_TABLES,TRADITIONAL")
16 )
17
18 def test_setoutputsize(self):
19 pass
20
21 def test_setoutputsize_basic(self):
22 pass
23
24 """The tests on fetchone and fetchall and rowcount bogusly
25 test for an exception if the statement cannot return a
26 result set. MySQL always returns a result set; it's just that
27 some things return empty result sets."""
28
29 def test_fetchall(self):
30 con = self._connect()
31 try:
32 cur = con.cursor()
33 # cursor.fetchall should raise an Error if called
34 # without executing a query that may return rows (such
35 # as a select)
36 self.assertRaises(self.driver.Error, cur.fetchall)
37
38 self.executeDDL1(cur)
39 for sql in self._populate():
40 cur.execute(sql)
41
42 # cursor.fetchall should raise an Error if called
43 # after executing a statement that cannot return rows
44 # self.assertRaises(self.driver.Error,cur.fetchall)
45
46 cur.execute("select name from %sbooze" % self.table_prefix)
47 rows = cur.fetchall()
48 self.assertTrue(cur.rowcount in (-1, len(self.samples)))
49 self.assertEqual(
50 len(rows),
51 len(self.samples),
52 "cursor.fetchall did not retrieve all rows",
53 )
54 rows = [r[0] for r in rows]
55 rows.sort()
56 for i in range(0, len(self.samples)):
57 self.assertEqual(
58 rows[i], self.samples[i], "cursor.fetchall retrieved incorrect rows"
59 )
60 rows = cur.fetchall()
61 self.assertEqual(
62 len(rows),
63 0,
64 "cursor.fetchall should return an empty list if called "
65 "after the whole result set has been fetched",
66 )
67 self.assertTrue(cur.rowcount in (-1, len(self.samples)))
68

Callers

nothing calls this directly

Calls 1

connection_kwargsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…