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

Class TestOldIssues

pymysql/tests/test_issues.py:14–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14class TestOldIssues(base.PyMySQLTestCase):
15 def test_issue_3(self):
16 """undefined methods datetime_or_None, date_or_None"""
17 conn = self.connect()
18 c = conn.cursor()
19 with warnings.catch_warnings():
20 warnings.filterwarnings("ignore")
21 c.execute("drop table if exists issue3")
22 c.execute("create table issue3 (d date, t time, dt datetime, ts timestamp)")
23 try:
24 c.execute(
25 "insert into issue3 (d, t, dt, ts) values (%s,%s,%s,%s)",
26 (None, None, None, None),
27 )
28 c.execute("select d from issue3")
29 self.assertEqual(None, c.fetchone()[0])
30 c.execute("select t from issue3")
31 self.assertEqual(None, c.fetchone()[0])
32 c.execute("select dt from issue3")
33 self.assertEqual(None, c.fetchone()[0])
34 c.execute("select ts from issue3")
35 self.assertIn(
36 type(c.fetchone()[0]),
37 (type(None), datetime.datetime),
38 "expected Python type None or datetime from SQL timestamp",
39 )
40 finally:
41 c.execute("drop table issue3")
42
43 def test_issue_4(self):
44 """can't retrieve TIMESTAMP fields"""
45 conn = self.connect()
46 c = conn.cursor()
47 with warnings.catch_warnings():
48 warnings.filterwarnings("ignore")
49 c.execute("drop table if exists issue4")
50 c.execute("create table issue4 (ts timestamp)")
51 try:
52 c.execute("insert into issue4 (ts) values (now())")
53 c.execute("select ts from issue4")
54 self.assertTrue(isinstance(c.fetchone()[0], datetime.datetime))
55 finally:
56 c.execute("drop table issue4")
57
58 def test_issue_5(self):
59 """query on information_schema.tables fails"""
60 con = self.connect()
61 cur = con.cursor()
62 cur.execute("select * from information_schema.tables")
63
64 def test_issue_6(self):
65 """exception: TypeError: ord() expected a character, but string of length 0 found"""
66 # ToDo: this test requires access to db 'mysql'.
67 kwargs = self.databases[0].copy()
68 kwargs["database"] = "mysql"
69 conn = pymysql.connect(**kwargs)
70 c = conn.cursor()
71 c.execute("select * from user")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected