web2py.py --run_system_tests, thanks Marc Abramowitz
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from pymysql.tests.test_issues import *
|
||||
from pymysql.tests.test_example import *
|
||||
from pymysql.tests.test_basic import *
|
||||
from gluon.contrib.pymysql.tests.test_issues import *
|
||||
from gluon.contrib.pymysql.tests.test_example import *
|
||||
from gluon.contrib.pymysql.tests.test_basic import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import pymysql
|
||||
from gluon.contrib import pymysql
|
||||
import unittest
|
||||
|
||||
class PyMySQLTestCase(unittest.TestCase):
|
||||
@@ -8,10 +8,13 @@ class PyMySQLTestCase(unittest.TestCase):
|
||||
{"host":"localhost","user":"root","passwd":"","db":"test_pymysql2"}]
|
||||
|
||||
def setUp(self):
|
||||
self.connections = []
|
||||
try:
|
||||
self.connections = []
|
||||
|
||||
for params in self.databases:
|
||||
self.connections.append(pymysql.connect(**params))
|
||||
for params in self.databases:
|
||||
self.connections.append(pymysql.connect(**params))
|
||||
except pymysql.err.OperationalError as e:
|
||||
self.skipTest('Cannot connect to MySQL - skipping pymysql tests because of (%s) %s' % (type(e), e))
|
||||
|
||||
def tearDown(self):
|
||||
for connection in self.connections:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from pymysql.tests import base
|
||||
from pymysql import util
|
||||
from gluon.contrib.pymysql.tests import base
|
||||
from gluon.contrib.pymysql import util
|
||||
|
||||
import time
|
||||
import datetime
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pymysql
|
||||
from pymysql.tests import base
|
||||
from gluon.contrib import pymysql
|
||||
from gluon.contrib.pymysql.tests import base
|
||||
|
||||
class TestExample(base.PyMySQLTestCase):
|
||||
def test_example(self):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pymysql
|
||||
from pymysql.tests import base
|
||||
from gluon.contrib import pymysql
|
||||
from gluon.contrib.pymysql.tests import base
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
@@ -55,6 +55,23 @@ if not sys.version[:3] in ['2.4', '2.5', '2.6', '2.7']:
|
||||
|
||||
logger = logging.getLogger("web2py")
|
||||
|
||||
def run_system_tests():
|
||||
major_version = sys.version_info[0]
|
||||
minor_version = sys.version_info[1]
|
||||
print "minor_version = %r" % minor_version
|
||||
if major_version == 2:
|
||||
if minor_version in (5, 6):
|
||||
print "Python 2.5 or 2.6"
|
||||
os.system("PYTHONPATH=. unit2 -v gluon.tests")
|
||||
elif minor_version in (7,):
|
||||
print "Python 2.7"
|
||||
os.system("PYTHONPATH=. python -m unittest -v gluon.tests")
|
||||
else:
|
||||
print "unknown python 2.x version"
|
||||
else:
|
||||
print "Only Python 2.x supported."
|
||||
|
||||
|
||||
class IO(object):
|
||||
""" """
|
||||
|
||||
@@ -735,6 +752,14 @@ def console():
|
||||
default=None,
|
||||
help=msg)
|
||||
|
||||
|
||||
msg = 'runs web2py tests'
|
||||
parser.add_option('--run_system_tests',
|
||||
action='store_true',
|
||||
dest='run_system_tests',
|
||||
default=False,
|
||||
help=msg)
|
||||
|
||||
if '-A' in sys.argv: k = sys.argv.index('-A')
|
||||
elif '--args' in sys.argv: k = sys.argv.index('--args')
|
||||
else: k=len(sys.argv)
|
||||
@@ -744,6 +769,10 @@ def console():
|
||||
global_settings.cmd_options = options
|
||||
global_settings.cmd_args = args
|
||||
|
||||
if options.run_system_tests:
|
||||
run_system_tests()
|
||||
sys.exit(0)
|
||||
|
||||
if options.quiet:
|
||||
capture = cStringIO.StringIO()
|
||||
sys.stdout = capture
|
||||
|
||||
Reference in New Issue
Block a user