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

Method test_load_warnings

pymysql/tests/test_load_local.py:69–98  ·  view source on GitHub ↗

Test load local infile produces the appropriate warnings

(self)

Source from the content-addressed store, hash-verified

67 c.execute("DROP TABLE test_load_local")
68
69 def test_load_warnings(self):
70 """Test load local infile produces the appropriate warnings"""
71 conn = self.connect()
72 c = conn.cursor()
73 c.execute("CREATE TABLE test_load_local (a INTEGER, b INTEGER)")
74 filename = os.path.join(
75 os.path.dirname(os.path.realpath(__file__)),
76 "data",
77 "load_local_warn_data.txt",
78 )
79 try:
80 c.execute(
81 (
82 "LOAD DATA LOCAL INFILE '{0}' INTO TABLE "
83 + "test_load_local FIELDS TERMINATED BY ','"
84 ).format(filename)
85 )
86 self.assertEqual(1, c.warning_count)
87
88 c.execute("SHOW WARNINGS")
89 w = c.fetchone()
90
91 self.assertEqual(ER.TRUNCATED_WRONG_VALUE_FOR_FIELD, w[1])
92 self.assertIn(
93 "incorrect integer value",
94 w[2].lower(),
95 )
96 finally:
97 c.execute("DROP TABLE test_load_local")
98 c.close()
99
100
101if __name__ == "__main__":

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected