summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2009-07-18 11:28:43 +1000
committerRobert Collins <robertc@robertcollins.net>2009-07-18 11:28:43 +1000
commite7a6b05f57ac47d58a000026eeb65a1cd4af6a79 (patch)
tree63f19f11fc669892785f36e5b848133032ca0250 /python
parent36a8fff948b6775ef1c6fc40edb68dcd89b0ed4e (diff)
parent2c2d6c715583f48c7180bfa64447f360c5de8fa3 (diff)
downloadsubunit-git-e7a6b05f57ac47d58a000026eeb65a1cd4af6a79.tar.gz
Merge python helper subunit.run, for running python suites in subunit.
Diffstat (limited to 'python')
-rwxr-xr-xpython/subunit/run.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/python/subunit/run.py b/python/subunit/run.py
new file mode 100755
index 0000000..5dad84a
--- /dev/null
+++ b/python/subunit/run.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+#
+# Simple subunit testrunner for python
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+
+from subunit import TestProtocolClient
+
+
+class SubunitTestRunner(object):
+ def __init__(self, stream=sys.stdout):
+ self.stream = stream
+
+ def run(self, test):
+ "Run the given test case or test suite."
+ result = TestProtocolClient(self.stream)
+ test(result)
+ return result
+
+
+if __name__ == '__main__':
+ import optparse
+ from unittest import TestProgram
+ parser = optparse.OptionParser("subunitrun <tests>")
+ args = parser.parse_args()[1]
+ runner = SubunitTestRunner()
+ program = TestProgram(module=None, argv=[sys.argv[0]] + args,
+ testRunner=runner)