Skip to content

Commit

Permalink
silence geom warnings. All geom functions are ST_geom in 5.7. silence…
Browse files Browse the repository at this point in the history
… charset warnings for now
  • Loading branch information
grooverdan committed Aug 26, 2015
1 parent 96f24ef commit b65da6f
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions pymysql/tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,21 +419,37 @@ def test_issue_364(self):

# test single insert and select
cur = conn.cursor()
cur.execute(sql, args=values)
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.execute(sql, args=values)
else:
cur.execute(sql, args=values)
cur.execute("select * from issue364")
self.assertEqual(cur.fetchone(), tuple(values))

# test single insert unicode query
cur.execute(usql, args=values)
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.execute(usql, args=values)
else:
cur.execute(usql, args=values)

# test multi insert and select
cur.executemany(sql, args=(values, values, values))
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.executemany(sql, args=(values, values, values))
else:
cur.executemany(sql, args=(values, values, values))
cur.execute("select * from issue364")
for row in cur.fetchall():
self.assertEqual(row, tuple(values))

# test multi insert with unicode query
cur.executemany(usql, args=(values, values, values))
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.executemany(usql, args=(values, values, values))
else:
cur.executemany(usql, args=(values, values, values))

def test_issue_363(self):
""" Test binary / geometry types. """
Expand All @@ -447,7 +463,7 @@ def test_issue_363(self):

cur = conn.cursor()
# FYI - not sure of 5.7.0 version
if sys.version_info[0:1] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.execute("INSERT INTO issue363 (id, geom) VALUES ("
"1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))")
Expand All @@ -456,12 +472,20 @@ def test_issue_363(self):
"1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))")

# select WKT
cur.execute("SELECT AsText(geom) FROM issue363")
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.execute("SELECT AsText(geom) FROM issue363")
else:
cur.execute("SELECT AsText(geom) FROM issue363")
row = cur.fetchone()
self.assertEqual(row, ("LINESTRING(1.1 1.1,2.2 2.2)", ))

# select WKB
cur.execute("SELECT AsBinary(geom) FROM issue363")
if sys.version_info[0:2] >= (3,2) and self.mysql_server_is(conn, (5, 7, 0)):
with self.assertWarns(pymysql.err.Warning) as cm:
cur.execute("SELECT AsBinary(geom) FROM issue363")
else:
cur.execute("SELECT AsBinary(geom) FROM issue363")
row = cur.fetchone()
self.assertEqual(row,
(b"\x01\x02\x00\x00\x00\x02\x00\x00\x00"
Expand Down

0 comments on commit b65da6f

Please sign in to comment.