3 # Simple subunit testrunner for python
4 # Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007
6 # Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
7 # license at the users choice. A copy of both licenses are available in the
8 # project source as Apache-2.0 and BSD. You may not use this file except in
9 # compliance with one of these two licences.
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # license you chose for the specific language governing permissions and
15 # limitations under that license.
18 """Run a unittest testcase reporting results as Subunit.
20 $ python -m subunit.run mylib.tests.test_suite
25 from subunit
import TestProtocolClient
, get_default_formatter
28 class SubunitTestRunner(object):
29 def __init__(self
, stream
=sys
.stdout
):
33 "Run the given test case or test suite."
34 result
= TestProtocolClient(self
.stream
)
39 if __name__
== '__main__':
41 from unittest
import TestProgram
42 parser
= optparse
.OptionParser(__doc__
)
43 args
= parser
.parse_args()[1]
44 stream
= get_default_formatter()
45 runner
= SubunitTestRunner(stream
)
46 program
= TestProgram(module
=None, argv
=[sys
.argv
[0]] + args
,