[Python-checkins] distutils2: added a global test script to make sure we test all python versions
tarek.ziade
python-checkins at python.org
Fri May 14 22:36:12 CEST 2010
tarek.ziade pushed d3c63381653d to distutils2:
http://hg.python.org/distutils2/rev/d3c63381653d
changeset: 142:d3c63381653d
user: Tarek Ziade <tarek at ziade.org>
date: Wed May 12 17:40:03 2010 +0200
summary: added a global test script to make sure we test all python versions
files: src/distutils2/tests/__init__.py, src/runtests.py, src/tests.sh
diff --git a/src/distutils2/tests/__init__.py b/src/distutils2/tests/__init__.py
--- a/src/distutils2/tests/__init__.py
+++ b/src/distutils2/tests/__init__.py
@@ -20,8 +20,6 @@
here = os.path.dirname(__file__)
-verbose = 1
-
def test_suite():
suite = unittest2.TestSuite()
@@ -48,10 +46,10 @@
return result
-def _run_suite(suite):
+def _run_suite(suite, verbose=1):
"""Run tests from a unittest2.TestSuite-derived class."""
if verbose:
- runner = unittest2.TextTestRunner(sys.stdout, verbosity=2)
+ runner = unittest2.TextTestRunner(sys.stdout, verbose=2)
else:
runner = BasicTestRunner()
@@ -66,7 +64,7 @@
raise TestFailed(err)
-def run_unittest(*classes):
+def run_unittest(classes, verbose=1):
"""Run tests from unittest2.TestCase-derived classes.
Extracted from stdlib test.test_support and modified to support unittest2.
@@ -83,7 +81,7 @@
suite.addTest(cls)
else:
suite.addTest(unittest2.makeSuite(cls))
- _run_suite(suite)
+ _run_suite(suite, verbose)
def reap_children():
diff --git a/src/runtests.py b/src/runtests.py
--- a/src/runtests.py
+++ b/src/runtests.py
@@ -2,17 +2,22 @@
The tests for distutils2 are defined in the distutils2.tests package;
"""
-
+import sys
import distutils2.tests
from distutils2.tests import run_unittest, reap_children
-
from distutils2._backport.tests import test_suite as btest_suite
def test_main():
- run_unittest(distutils2.tests.test_suite())
- run_unittest(btest_suite())
+ # just supporting -q right now
+ # to enable detailed/quiet output
+ if len(sys.argv) > 1:
+ verbose = sys.argv[-1] != '-q'
+ else:
+ verbose = 1
+
+ run_unittest([distutils2.tests.test_suite(), btest_suite()],
+ verbose=verbose)
reap_children()
-
if __name__ == "__main__":
test_main()
diff --git a/src/tests.sh b/src/tests.sh
new file mode 100755
--- /dev/null
+++ b/src/tests.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+python2.4 runtests.py -q
+python2.5 runtests.py -q
+python2.6 runtests.py -q
+
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list