Replace test runners with nose, and add tox support.

Reviewed in: https://codereview.appspot.com/6490081/
This commit is contained in:
Ali Afshar
2012-09-06 08:43:10 -07:00
parent 7972f35985
commit 02b5f3f369
7 changed files with 43 additions and 72 deletions

View File

@@ -7,6 +7,7 @@ syntax: glob
*/.git/* */.git/*
*/.cache/* */.cache/*
.gitignore .gitignore
.tox
samples/buzz/*.dat samples/buzz/*.dat
samples/moderator/*.dat samples/moderator/*.dat
htmlcov/* htmlcov/*

View File

@@ -4,9 +4,7 @@ pep8:
APP_ENGINE_PATH=../google_appengine APP_ENGINE_PATH=../google_appengine
test: test:
./runtests.sh python2.6 tox
./runtests.sh python2.7
.PHONY: coverage .PHONY: coverage
coverage: coverage:

View File

@@ -1,45 +0,0 @@
#!/usr/bin/env python
import gflags
import glob
import imp
import logging
import os
import sys
import unittest
# import oauth2client.util for its gflags.
import oauth2client.util
from trace import fullmodname
logging.basicConfig(level=logging.CRITICAL)
FLAGS = gflags.FLAGS
APP_ENGINE_PATH='../google_appengine'
# Conditional import of cleanup function
try:
from tests.utils import cleanup
except:
def cleanup():
pass
# Ensure current working directory is in path
sys.path.insert(0, os.getcwd())
sys.path.insert(0, APP_ENGINE_PATH)
from google.appengine.dist import use_library
use_library('django', '1.2')
def main(argv):
argv = FLAGS(argv)
for t in argv[1:]:
module = imp.load_source('test', t)
test = unittest.TestLoader().loadTestsFromModule(module)
result = unittest.TextTestRunner(verbosity=1).run(test)
if __name__ == '__main__':
main(sys.argv)

View File

@@ -1,24 +0,0 @@
#/bin/bash
#
# Run all the tests.
#
# The python interpreter to use is passed in on the command line.
FLAGS=--positional_parameters_enforcement=EXCEPTION
$1 runtests.py $FLAGS tests/test_discovery.py
$1 runtests.py $FLAGS tests/test_errors.py
$1 runtests.py $FLAGS tests/test_http.py
$1 runtests.py $FLAGS tests/test_json_model.py
$1 runtests.py $FLAGS tests/test_mocks.py
$1 runtests.py $FLAGS tests/test_model.py
$1 runtests.py $FLAGS tests/test_oauth2client_clientsecrets.py
$1 runtests.py $FLAGS tests/test_oauth2client_django_orm.py
$1 runtests.py $FLAGS tests/test_oauth2client_file.py
$1 runtests.py $FLAGS tests/test_oauth2client_jwt.py
$1 runtests.py $FLAGS tests/test_oauth2client.py
$1 runtests.py $FLAGS tests/test_protobuf_model.py
$1 runtests.py $FLAGS tests/test_schema.py
$1 runtests.py $FLAGS tests/test_oauth2client_appengine.py
$1 runtests.py $FLAGS tests/test_oauth2client_keyring.py
$1 runtests.py $FLAGS tests/test_oauth2client_gce.py
$1 runtests.py $FLAGS tests/test_oauth2client_xsrfutil.py

View File

@@ -0,0 +1,22 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test Package set up."""
__author__ = 'afshar@google.com (Ali Afshar)'
import gflags
def setup_package():
"""Run on testing package."""
FLAGS = gflags.FLAGS
FLAGS.positional_parameters_enforcement = 'EXCEPTION'

View File

@@ -29,6 +29,13 @@ import pickle
import sys import sys
import unittest import unittest
# Ensure that if app engine is available, we use the correct django from it
try:
from google.appengine.dist import use_library
use_library('django', '1.2')
except ImportError:
pass
from oauth2client.client import Credentials from oauth2client.client import Credentials
from oauth2client.client import Flow from oauth2client.client import Flow

12
tox.ini Normal file
View File

@@ -0,0 +1,12 @@
[tox]
envlist = py26,py27
[testenv]
deps = keyring
mox
pyopenssl
django==1.2
webtest
nose
setenv = PYTHONPATH=../google_appengine
commands = nosetests