'Test binary / geometry types.'

def test_issue_363(self):

    conn = pymysql.connect(charset='utf8', **self.databases[0])
    self.safe_create_table(conn, 'issue363', 'CREATE    TABLE    issue363    (    id    INTEGER    PRIMARY    KEY,    geom    LINESTRING    NOT    NULL,    SPATIAL    KEY    geom    (geom))    ENGINE=MyISAM    default    charset=utf8')
    cur = conn.cursor()
    query = "INSERT    INTO    issue363    (id,    geom)    VALUES(1998,    GeomFromText('LINESTRING(1.1    1.1,2.2    2.2)'))"
    if self.mysql_server_is(conn, (5, 7, 0)):
        with self.assertWarns(pymysql.err.Warning) as cm:
            cur.execute(query)
    else:
        cur.execute(query)
    query = 'SELECT    AsText(geom)    FROM    issue363'
    if self.mysql_server_is(conn, (5, 7, 0)):
        with self.assertWarns(pymysql.err.Warning) as cm:
            cur.execute(query)
    else:
        cur.execute(query)
    row = cur.fetchone()
    self.assertEqual(row, ('LINESTRING(1.1    1.1,2.2    2.2)',))
    query = 'SELECT    AsBinary(geom)    FROM    issue363'
    if self.mysql_server_is(conn, (5, 7, 0)):
        with self.assertWarns(pymysql.err.Warning) as cm:
            cur.execute(query)
    else:
        cur.execute(query)
    row = cur.fetchone()
    self.assertEqual(row, ('\x01\x02\x00\x00\x00\x02\x00\x00\x00\x9a\x99\x99\x99\x99\x99\xf1?\x9a\x99\x99\x99\x99\x99\xf1?\x9a\x99\x99\x99\x99\x99\x01@\x9a\x99\x99\x99\x99\x99\x01@',))
    cur.execute('SELECT    geom    FROM    issue363')
    row = cur.fetchone()
    self.assertTrue(isinstance(row[0], bytes))
