~ubuntu-branches/debian/sid/subunit/sid

« back to all changes in this revision

Viewing changes to filters/subunit2junitxml

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-08 21:44:01 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120408214401-7uyuh0zhx7lvpp7j
Tags: 0.0.7+bzr162-1
* New upstream snapshot.
 + Fixes compatibility with current versions of testtools. Closes: #669491
* Support installation for multiple python versions.
* Include egg-info for python-subunit. LP: #893620
* Add python3-subunit package.
* Bump standards version to 3.9.3 (no changes).
* Use machine parseable format for copyright file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Filter a subunit stream to get aggregate statistics."""
18
18
 
19
 
from optparse import OptionParser
 
19
 
20
20
import sys
21
 
import unittest
 
21
from subunit.filters import run_filter_script
22
22
 
23
 
from subunit import DiscardStream, ProtocolTestCase
24
23
try:
25
24
    from junitxml import JUnitXmlResult
26
25
except ImportError:
28
27
        "http://pypi.python.org/pypi/junitxml) is required for this filter.")
29
28
    raise
30
29
 
31
 
parser = OptionParser(description=__doc__)
32
 
parser.add_option("--no-passthrough", action="store_true",
33
 
    help="Hide all non subunit input.", default=False, dest="no_passthrough")
34
 
parser.add_option("-o", "--output-to",
35
 
    help="Output the XML to this path rather than stdout.")
36
 
parser.add_option("-f", "--forward", action="store_true", default=False,
37
 
    help="Forward subunit stream on stdout.")
38
 
(options, args) = parser.parse_args()
39
 
if options.output_to is None:
40
 
    output_to = sys.stdout
41
 
else:
42
 
    output_to = file(options.output_to, 'wb')
43
 
try:
44
 
    result = JUnitXmlResult(output_to)
45
 
    if options.no_passthrough:
46
 
        passthrough_stream = DiscardStream()
47
 
    else:
48
 
        passthrough_stream = None
49
 
    if options.forward:
50
 
        forward_stream = sys.stdout
51
 
    else:
52
 
        forward_stream = None
53
 
    test = ProtocolTestCase(sys.stdin, passthrough=passthrough_stream,
54
 
       forward=forward_stream)
55
 
    result.startTestRun()
56
 
    test.run(result)
57
 
    result.stopTestRun()
58
 
finally:
59
 
    if options.output_to is not None:
60
 
        output_to.close()
61
 
if result.wasSuccessful():
62
 
    exit_code = 0
63
 
else:
64
 
    exit_code = 1
65
 
sys.exit(exit_code)
 
30
 
 
31
run_filter_script(JUnitXmlResult, __doc__)