This commit is contained in:
INADA Naoki
2015-11-05 03:38:13 +09:00
parent b07937487d
commit 98bec5fb8c
5 changed files with 238 additions and 237 deletions

View File

@ -111,7 +111,7 @@ class BaseCursor(object):
if self._warnings: if self._warnings:
# When there is next result, fetching warnings cause "command # When there is next result, fetching warnings cause "command
# out of sync" error. # out of sync" error.
if self._result.has_next: if self._result and self._result.has_next:
msg = "There are %d MySQL warnings." % (self._warnings,) msg = "There are %d MySQL warnings." % (self._warnings,)
self.messages.append(msg) self.messages.append(msg)
warn(msg, self.Warning, 3) warn(msg, self.Warning, 3)

View File

@ -10,16 +10,15 @@ connect_kwargs = dict(
read_default_group = "MySQLdb-tests", read_default_group = "MySQLdb-tests",
) )
def connection_kwargs(kwargs): def connection_kwargs(kwargs):
db_kwargs = connect_kwargs.copy() db_kwargs = connect_kwargs.copy()
db_kwargs.update(kwargs) db_kwargs.update(kwargs)
return db_kwargs return db_kwargs
def connection_factory(**kwargs): def connection_factory(**kwargs):
import MySQLdb import MySQLdb
db_kwargs = connection_kwargs(kwargs) db_kwargs = connection_kwargs(kwargs)
db = MySQLdb.connect(**db_kwargs) db = MySQLdb.connect(**db_kwargs)
return db return db

View File

@ -6,6 +6,7 @@ from configdb import connection_kwargs
import warnings import warnings
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
class test_MySQLdb(dbapi20.DatabaseAPI20Test): class test_MySQLdb(dbapi20.DatabaseAPI20Test):
driver = MySQLdb driver = MySQLdb
connect_args = () connect_args = ()
@ -35,7 +36,7 @@ class test_MySQLdb(dbapi20.DatabaseAPI20Test):
# cursor.fetchall should raise an Error if called # cursor.fetchall should raise an Error if called
# after executing a a statement that cannot return rows # after executing a a statement that cannot return rows
## self.assertRaises(self.driver.Error,cur.fetchall) #self.assertRaises(self.driver.Error,cur.fetchall)
cur.execute('select name from %sbooze' % self.table_prefix) cur.execute('select name from %sbooze' % self.table_prefix)
rows = cur.fetchall() rows = cur.fetchall()
@ -164,11 +165,11 @@ class test_MySQLdb(dbapi20.DatabaseAPI20Test):
cur.execute("drop procedure deleteme") cur.execute("drop procedure deleteme")
def test_nextset(self): def test_nextset(self):
from warnings import warn #from warnings import warn
con = self._connect() con = self._connect()
try: try:
cur = con.cursor() cur = con.cursor()
if not hasattr(cur,'nextset'): if not hasattr(cur, 'nextset'):
return return
try: try:

View File

@ -7,6 +7,7 @@ from configdb import connection_factory
import warnings import warnings
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
class TestDBAPISet(unittest.TestCase): class TestDBAPISet(unittest.TestCase):
def test_set_equality(self): def test_set_equality(self):
self.assertTrue(MySQLdb.STRING == MySQLdb.STRING) self.assertTrue(MySQLdb.STRING == MySQLdb.STRING)
@ -21,7 +22,7 @@ class TestDBAPISet(unittest.TestCase):
self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING) self.assertTrue(FIELD_TYPE.DATE != MySQLdb.STRING)
class CoreModule(unittest.TestCase): class TestCoreModule(unittest.TestCase):
"""Core _mysql module features.""" """Core _mysql module features."""
def test_NULL(self): def test_NULL(self):