refactoring of tests and created a test case for the example

This commit is contained in:
Pete Hunt
2010-07-30 14:32:31 +00:00
parent 830e4786c1
commit d22549e1f8
3 changed files with 38 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
import pymysql
import unittest
class PyMySqlTestCase(unittest.TestCase):
class PyMySQLTestCase(unittest.TestCase):
databases = [
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql"},
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]

View File

@@ -0,0 +1,32 @@
import pymysql
from pymysql.tests import base
class TestExample(base.PyMySQLTestCase):
def test_example(self):
conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='', db='mysql')
cur = conn.cursor()
cur.execute("SELECT Host,User FROM user")
# print cur.description
# r = cur.fetchall()
# print r
# ...or...
u = False
for r in cur.fetchall():
u = u or conn.user in r
self.assertTrue(u)
cur.close()
conn.close()
if __name__ == "__main__":
import unittest
unittest.main()

View File

@@ -1,5 +1,5 @@
import pymysql
import base
from pymysql.tests import base
try:
import imp
@@ -9,7 +9,7 @@ except AttributeError:
import datetime
class TestOldIssues(base.PyMySqlTestCase):
class TestOldIssues(base.PyMySQLTestCase):
def test_issue_3(self):
""" undefined methods datetime_or_None, date_or_None """
conn = self.connections[0]
@@ -150,6 +150,9 @@ KEY (`station`,`dh`,`echeance`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;""")
finally:
c.execute("drop table issue17")
class TestNewIssues(base.PyMySQLTestCase):
pass
if __name__ == "__main__":
import unittest
unittest.main()