fixed logic for running tests and using welcome for testing, thanks Paolo
This commit is contained in:
4
Makefile
4
Makefile
@@ -19,11 +19,11 @@ clean:
|
|||||||
find applications/welcome/ -name '.*' -exec rm -f {} \;
|
find applications/welcome/ -name '.*' -exec rm -f {} \;
|
||||||
find . -name '*.pyc' -exec rm -f {} \;
|
find . -name '*.pyc' -exec rm -f {} \;
|
||||||
tests:
|
tests:
|
||||||
python web2py.py --run_system_tests
|
python web2py.py --verbose --run_system_tests
|
||||||
coverage:
|
coverage:
|
||||||
coverage erase --rcfile=gluon/tests/coverage.ini
|
coverage erase --rcfile=gluon/tests/coverage.ini
|
||||||
export COVERAGE_PROCESS_START=gluon/tests/coverage.ini
|
export COVERAGE_PROCESS_START=gluon/tests/coverage.ini
|
||||||
python web2py.py --run_system_tests --with_coverage
|
python web2py.py --verbose --run_system_tests --with_coverage
|
||||||
coverage combine --rcfile=gluon/tests/coverage.ini
|
coverage combine --rcfile=gluon/tests/coverage.ini
|
||||||
sleep 1
|
sleep 1
|
||||||
coverage html --rcfile=gluon/tests/coverage.ini
|
coverage html --rcfile=gluon/tests/coverage.ini
|
||||||
|
|||||||
@@ -14,9 +14,8 @@ import shutil
|
|||||||
|
|
||||||
from gluon.contrib.webclient import WebClient
|
from gluon.contrib.webclient import WebClient
|
||||||
from gluon._compat import urllib2, PY2
|
from gluon._compat import urllib2, PY2
|
||||||
from gluon.fileutils import create_app
|
|
||||||
|
|
||||||
test_app_name = '_test_web'
|
test_app_name = 'welcome'
|
||||||
|
|
||||||
webserverprocess = None
|
webserverprocess = None
|
||||||
|
|
||||||
@@ -37,8 +36,8 @@ def startwebserver():
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print("%d..." % a)
|
print("%d..." % a)
|
||||||
try:
|
try:
|
||||||
c = WebClient('http://127.0.0.1:8000/' + test_app_name)
|
c = WebClient('http://127.0.0.1:8000/')
|
||||||
c.get('/')
|
c.get(test_app_name)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
@@ -73,18 +72,28 @@ class LiveTest(unittest.TestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
appdir = os.path.join('applications', test_app_name)
|
# FIXME: should use a temporary application to run tests,
|
||||||
if not os.path.exists(appdir):
|
# instead of tampering an existing one, whatever it is;
|
||||||
os.mkdir(appdir)
|
# rename databases dir to databases~ and use a blank
|
||||||
create_app(appdir)
|
# databases during tests
|
||||||
|
dbdir = os.path.join('applications', test_app_name, 'databases')
|
||||||
|
if os.path.exists(dbdir):
|
||||||
|
bakdbdir = dbdir + '~'
|
||||||
|
if os.path.exists(bakdbdir):
|
||||||
|
shutil.rmtree(dbdir)
|
||||||
|
else:
|
||||||
|
os.rename(dbdir, bakdbdir)
|
||||||
|
os.mkdir(dbdir)
|
||||||
startwebserver()
|
startwebserver()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
stopwebserver()
|
stopwebserver()
|
||||||
appdir = os.path.join('applications', test_app_name)
|
dbdir = os.path.join('applications', test_app_name, 'databases')
|
||||||
if os.path.exists(appdir):
|
shutil.rmtree(dbdir)
|
||||||
shutil.rmtree(appdir)
|
bakdbdir = dbdir + '~'
|
||||||
|
if os.path.exists(bakdbdir):
|
||||||
|
os.rename(bakdbdir, dbdir)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf("datastore" in os.getenv("DB", ""), "TODO: setup web test for app engine")
|
@unittest.skipIf("datastore" in os.getenv("DB", ""), "TODO: setup web test for app engine")
|
||||||
|
|||||||
Reference in New Issue
Block a user