~bzr/ubuntu/hardy/subunit/bzr-ppa

« back to all changes in this revision

Viewing changes to filters/subunit2pyunit

  • Committer: Robert Collins
  • Date: 2009-09-20 02:16:29 UTC
  • mfrom: (73.1.11 debian)
  • Revision ID: robertc@robertcollins.net-20090920021629-r3mal3003qren1or
Merge 0.0.2 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
#
19
19
 
20
 
"""Filter a subunit stream through python's default unittest test runner."""
 
20
"""Display a subunit stream through python's unittest test runner."""
21
21
 
 
22
from optparse import OptionParser
22
23
import sys
23
24
import unittest
24
25
 
25
 
from subunit import ProtocolTestCase, TestProtocolServer
 
26
from subunit import DiscardStream, ProtocolTestCase, TestProtocolServer
26
27
 
27
 
runner = unittest.TextTestRunner(verbosity=2)
28
 
test = ProtocolTestCase(sys.stdin)
 
28
parser = OptionParser(description=__doc__)
 
29
parser.add_option("--no-passthrough", action="store_true",
 
30
    help="Hide all non subunit input.", default=False, dest="no_passthrough")
 
31
parser.add_option("--progress", action="store_true",
 
32
    help="Use bzrlib's test reporter (requires bzrlib)",
 
33
        default=False)
 
34
(options, args) = parser.parse_args()
 
35
if options.no_passthrough:
 
36
    passthrough_stream = DiscardStream()
 
37
else:
 
38
    passthrough_stream = None
 
39
test = ProtocolTestCase(sys.stdin, passthrough=passthrough_stream)
 
40
if options.progress:
 
41
    from bzrlib.tests import TextTestRunner
 
42
    from bzrlib import ui
 
43
    ui.ui_factory = ui.make_ui_for_terminal(None, sys.stdout, sys.stderr)
 
44
    runner = TextTestRunner()
 
45
else:
 
46
    runner = unittest.TextTestRunner(verbosity=2)
29
47
if runner.run(test).wasSuccessful():
30
48
    exit_code = 0
31
49
else: