summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-11 01:31:24 +0530
committerYesudeep Mangalapilly <yesudeep@gmail.com>2011-08-11 01:31:24 +0530
commit50fd52fa2fb10e042ef81ba8b1ee57d2d203655c (patch)
tree73e71c74d297c8bf2b45510d7658117aa4d2b8ce
parentf5b88e81f3b82a27c3eaff55796ff7a6a4de9089 (diff)
downloadrsa-50fd52fa2fb10e042ef81ba8b1ee57d2d203655c.tar.gz
Adds tox configuration to test with multiple python versions.
-rw-r--r--.gitignore3
-rw-r--r--.hgignore3
-rw-r--r--run_tests.py43
-rw-r--r--tox.ini32
4 files changed, 81 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index d0e46f9..f260764 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@
dist/
distribute*.tar.gz
distribute*.egg
+
+.tox/
+.coverage
diff --git a/.hgignore b/.hgignore
index b6258d8..a5db5a2 100644
--- a/.hgignore
+++ b/.hgignore
@@ -6,3 +6,6 @@ dist/
rsa.egg-info/
distribute-0.6.*
doc/_build/
+.tox/
+.coverage
+.idea/
diff --git a/run_tests.py b/run_tests.py
new file mode 100644
index 0000000..e0f2490
--- /dev/null
+++ b/run_tests.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import unittest2 as unittest
+
+current_path = os.path.abspath(os.path.dirname(__file__))
+tests_path = os.path.join(current_path, 'tests')
+sys.path[0:0] = [
+ current_path,
+ tests_path,
+]
+
+all_tests = [f[:-3] for f in os.listdir(tests_path)
+ if f.startswith('test_') and f.endswith(".py")]
+
+def get_suite(tests):
+ tests = sorted(tests)
+ suite = unittest.TestSuite()
+ loader = unittest.TestLoader()
+ for test in tests:
+ suite.addTest(loader.loadTestsFromName(test))
+ return suite
+
+if __name__ == '__main__':
+ """
+ To run all tests:
+ $ python run_tests.py
+ To run a single test:
+ $ python run_tests.py app
+ To run a couple of tests:
+ $ python run_tests.py app config sessions
+ To run code coverage:
+ $ coverage run run_tests.py
+ $ coverage report -m
+ """
+ tests = sys.argv[1:]
+ if not tests:
+ tests = all_tests
+ tests = ['%s' % t for t in tests]
+ suite = get_suite(tests)
+ unittest.TextTestRunner(verbosity=1).run(suite)
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..9f0ed5e
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,32 @@
+[tox]
+envlist = py25,py26,py27,py32 #,pypy
+
+[testenv]
+commands=coverage erase
+ coverage run run_tests.py
+ coverage report -m
+ #coverage html -d htmlcov
+
+[testenv:py25]
+deps=pyasn1 >=0.0.13
+ coverage >=3.5
+ unittest2
+
+[testenv:py26]
+deps=pyasn1 >=0.0.13
+ coverage >=3.5
+ unittest2
+
+[testenv:py27]
+deps=pyasn1 >=0.0.13
+ coverage >=3.5
+ unittest2
+
+[testenv:py32]
+deps=coverage >= 3.5
+ unittest2py3k
+
+[testenv:pypy]
+deps=pyasn1 >=0.0.13
+ coverage >= 3.5
+ unittest2