aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Afshar <afshar@google.com>2012-09-06 08:43:10 -0700
committerAli Afshar <afshar@google.com>2012-09-06 08:43:10 -0700
commit02b5f3f369d9dceaf197eac540ce5797d1a07250 (patch)
tree564387ba37322109060422e671ed8d27458db183
parent7972f35985a794812d0f03f0cf76e0a8b0ffec22 (diff)
downloadgoogle-api-python-client-02b5f3f369d9dceaf197eac540ce5797d1a07250.tar.gz
Replace test runners with nose, and add tox support.
Reviewed in: https://codereview.appspot.com/6490081/
-rw-r--r--.hgignore1
-rw-r--r--Makefile4
-rw-r--r--runtests.py45
-rwxr-xr-xruntests.sh24
-rw-r--r--tests/__init__.py22
-rw-r--r--tests/test_oauth2client_django_orm.py7
-rw-r--r--tox.ini12
7 files changed, 43 insertions, 72 deletions
diff --git a/.hgignore b/.hgignore
index 940640836..38ec00f3c 100644
--- a/.hgignore
+++ b/.hgignore
@@ -7,6 +7,7 @@ syntax: glob
*/.git/*
*/.cache/*
.gitignore
+.tox
samples/buzz/*.dat
samples/moderator/*.dat
htmlcov/*
diff --git a/Makefile b/Makefile
index 1e66c3a71..8102da71d 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,7 @@ pep8:
APP_ENGINE_PATH=../google_appengine
test:
- ./runtests.sh python2.6
- ./runtests.sh python2.7
-
+ tox
.PHONY: coverage
coverage:
diff --git a/runtests.py b/runtests.py
deleted file mode 100644
index 0176cc734..000000000
--- a/runtests.py
+++ /dev/null
@@ -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)
diff --git a/runtests.sh b/runtests.sh
deleted file mode 100755
index 9b4ba05a5..000000000
--- a/runtests.sh
+++ /dev/null
@@ -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
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29bb..245199564 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -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'
diff --git a/tests/test_oauth2client_django_orm.py b/tests/test_oauth2client_django_orm.py
index dbd2e20da..c80ff1dbf 100644
--- a/tests/test_oauth2client_django_orm.py
+++ b/tests/test_oauth2client_django_orm.py
@@ -29,6 +29,13 @@ import pickle
import sys
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 Flow
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 000000000..14ccd0442
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+envlist = py26,py27
+
+[testenv]
+deps = keyring
+ mox
+ pyopenssl
+ django==1.2
+ webtest
+ nose
+setenv = PYTHONPATH=../google_appengine
+commands = nosetests