refactoring of tests and created a test case for the example
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import pymysql
|
import pymysql
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class PyMySqlTestCase(unittest.TestCase):
|
class PyMySQLTestCase(unittest.TestCase):
|
||||||
databases = [
|
databases = [
|
||||||
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql"},
|
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql"},
|
||||||
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]
|
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]
|
||||||
|
|||||||
32
pymysql/tests/test_example.py
Normal file
32
pymysql/tests/test_example.py
Normal 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()
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import pymysql
|
import pymysql
|
||||||
import base
|
from pymysql.tests import base
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import imp
|
import imp
|
||||||
@@ -9,7 +9,7 @@ except AttributeError:
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
class TestOldIssues(base.PyMySqlTestCase):
|
class TestOldIssues(base.PyMySQLTestCase):
|
||||||
def test_issue_3(self):
|
def test_issue_3(self):
|
||||||
""" undefined methods datetime_or_None, date_or_None """
|
""" undefined methods datetime_or_None, date_or_None """
|
||||||
conn = self.connections[0]
|
conn = self.connections[0]
|
||||||
@@ -150,6 +150,9 @@ KEY (`station`,`dh`,`echeance`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;""")
|
|||||||
finally:
|
finally:
|
||||||
c.execute("drop table issue17")
|
c.execute("drop table issue17")
|
||||||
|
|
||||||
|
class TestNewIssues(base.PyMySQLTestCase):
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import unittest
|
import unittest
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
Reference in New Issue
Block a user