mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 02:54:29 +08:00
Some (many) tests actually pass now on Python 3. May no longer be backwards-compatible with Python < 2.6.
This commit is contained in:
@ -77,7 +77,7 @@ def Binary(x):
|
||||
|
||||
def Connect(*args, **kwargs):
|
||||
"""Factory function for connections.Connection."""
|
||||
from connections import Connection
|
||||
from MySQLdb.connections import Connection
|
||||
return Connection(*args, **kwargs)
|
||||
|
||||
connect = Connection = Connect
|
||||
|
@ -6,7 +6,7 @@ want to make your own subclasses. In most cases, you will probably
|
||||
override Connection.default_cursor with a non-standard Cursor class.
|
||||
|
||||
"""
|
||||
import cursors
|
||||
from MySQLdb import cursors
|
||||
from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
|
||||
DatabaseError, OperationalError, IntegrityError, InternalError, \
|
||||
NotSupportedError, ProgrammingError
|
||||
@ -33,7 +33,7 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
|
||||
connection.messages.append(error)
|
||||
del cursor
|
||||
del connection
|
||||
raise errorclass, errorvalue
|
||||
raise errorclass(errorvalue)
|
||||
|
||||
re_numeric_part = re.compile(r"^(\d+)")
|
||||
|
||||
@ -143,8 +143,8 @@ class Connection(_mysql.connection):
|
||||
documentation for the MySQL C API for some hints on what they do.
|
||||
|
||||
"""
|
||||
from constants import CLIENT, FIELD_TYPE
|
||||
from converters import conversions
|
||||
from MySQLdb.constants import CLIENT, FIELD_TYPE
|
||||
from MySQLdb.converters import conversions
|
||||
from weakref import proxy, WeakValueDictionary
|
||||
|
||||
import types
|
||||
|
@ -33,8 +33,8 @@ MySQL.connect().
|
||||
"""
|
||||
|
||||
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
|
||||
from constants import FIELD_TYPE, FLAG
|
||||
from times import *
|
||||
from MySQLdb.constants import FIELD_TYPE, FLAG
|
||||
from MySQLdb.times import *
|
||||
import types
|
||||
import array
|
||||
|
||||
|
@ -7,8 +7,13 @@ default, MySQLdb uses the Cursor class.
|
||||
|
||||
import re
|
||||
import sys
|
||||
from types import ListType, TupleType, UnicodeType
|
||||
|
||||
try:
|
||||
from types import ListType, TupleType, UnicodeType
|
||||
except ImportError:
|
||||
# Python 3
|
||||
ListType = list
|
||||
TupleType = tuple
|
||||
UnicodeType = str
|
||||
|
||||
restr = (r"\svalues\s*"
|
||||
r"(\(((?<!\\)'[^\)]*?\)[^\)]*(?<!\\)?'"
|
||||
@ -161,7 +166,7 @@ class BaseCursor(object):
|
||||
try:
|
||||
r = None
|
||||
r = self._query(query)
|
||||
except TypeError, m:
|
||||
except TypeError as m:
|
||||
if m.args[0] in ("not enough arguments for format string",
|
||||
"not all arguments converted"):
|
||||
self.messages.append((ProgrammingError, m.args[0]))
|
||||
@ -212,7 +217,7 @@ class BaseCursor(object):
|
||||
qv = m.group(1)
|
||||
try:
|
||||
q = [ qv % db.literal(a) for a in args ]
|
||||
except TypeError, msg:
|
||||
except TypeError as msg:
|
||||
if msg.args[0] in ("not enough arguments for format string",
|
||||
"not all arguments converted"):
|
||||
self.errorhandler(self, ProgrammingError, msg.args[0])
|
||||
@ -365,7 +370,7 @@ class CursorStoreResultMixIn(object):
|
||||
r = value
|
||||
else:
|
||||
self.errorhandler(self, ProgrammingError,
|
||||
"unknown scroll mode %s" % `mode`)
|
||||
"unknown scroll mode %s" % repr(mode))
|
||||
if r < 0 or r >= len(self._rows):
|
||||
self.errorhandler(self, IndexError, "out of range")
|
||||
self.rownumber = r
|
||||
|
@ -2979,8 +2979,8 @@ init_mysql(void)
|
||||
if (!module) return; /* this really should never happen */
|
||||
#endif
|
||||
#ifdef IS_PY3K
|
||||
/* Py_TYPE(_mysql_ConnectionObject_Type) = &PyType_Type;
|
||||
Py_TYPE(_mysql_ResultObject_Type) = &PyType_Type; */
|
||||
Py_TYPE(&_mysql_ConnectionObject_Type) = &PyType_Type;
|
||||
Py_TYPE(&_mysql_ResultObject_Type) = &PyType_Type;
|
||||
#else
|
||||
_mysql_ConnectionObject_Type.ob_type = &PyType_Type;
|
||||
_mysql_ResultObject_Type.ob_type = &PyType_Type;
|
||||
|
@ -706,7 +706,7 @@ class DatabaseAPI20Test(unittest.TestCase):
|
||||
that returns two result sets, first the
|
||||
number of rows in booze then "name from booze"
|
||||
'''
|
||||
raise NotImplementedError,'Helper not implemented'
|
||||
raise NotImplementedError('Helper not implemented')
|
||||
#sql="""
|
||||
# create procedure deleteme as
|
||||
# begin
|
||||
@ -718,7 +718,7 @@ class DatabaseAPI20Test(unittest.TestCase):
|
||||
|
||||
def help_nextset_tearDown(self,cur):
|
||||
'If cleaning up is needed after nextSetTest'
|
||||
raise NotImplementedError,'Helper not implemented'
|
||||
raise NotImplementedError('Helper not implemented')
|
||||
#cur.execute("drop procedure deleteme")
|
||||
|
||||
def test_nextset(self):
|
||||
@ -751,7 +751,7 @@ class DatabaseAPI20Test(unittest.TestCase):
|
||||
con.close()
|
||||
|
||||
def test_nextset(self):
|
||||
raise NotImplementedError,'Drivers need to override this test'
|
||||
raise NotImplementedError('Drivers need to override this test')
|
||||
|
||||
def test_arraysize(self):
|
||||
# Not much here - rest of the tests for this are in test_fetchmany
|
||||
@ -786,7 +786,7 @@ class DatabaseAPI20Test(unittest.TestCase):
|
||||
|
||||
def test_setoutputsize(self):
|
||||
# Real test for setoutputsize is driver dependant
|
||||
raise NotImplementedError,'Driver need to override this test'
|
||||
raise NotImplementedError('Driver need to override this test')
|
||||
|
||||
def test_None(self):
|
||||
con = self._connect()
|
||||
|
@ -77,7 +77,7 @@ class test_MySQLdb(capabilities.DatabaseTest):
|
||||
from MySQLdb.constants import ER
|
||||
try:
|
||||
self.cursor.execute("describe some_non_existent_table");
|
||||
except self.connection.ProgrammingError as msg:
|
||||
except self.connection.ProgrammingError as (msg,):
|
||||
self.assertTrue(msg[0] == ER.NO_SUCH_TABLE)
|
||||
|
||||
def test_bug_3514287(self):
|
||||
|
@ -203,4 +203,3 @@ class test_MySQLdb(dbapi20.DatabaseAPI20Test):
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
print '''"Huh-huh, he said 'unit'." -- Butthead'''
|
||||
|
Reference in New Issue
Block a user