diff options
Diffstat (limited to 'lib/subunit/python/subunit/__init__.py')
-rw-r--r-- | lib/subunit/python/subunit/__init__.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/subunit/python/subunit/__init__.py b/lib/subunit/python/subunit/__init__.py index 6e8df90317..6b65ae42dc 100644 --- a/lib/subunit/python/subunit/__init__.py +++ b/lib/subunit/python/subunit/__init__.py @@ -213,10 +213,10 @@ class _ParserState(object): def lineReceived(self, line): """a line has been received.""" parts = line.split(None, 1) - if len(parts) == 2: + if len(parts) == 2 and line.startswith(parts[0]): cmd, rest = parts offset = len(cmd) + 1 - cmd = cmd.strip(':') + cmd = cmd.rstrip(':') if cmd in ('test', 'testing'): self.startTest(offset, line) elif cmd == 'error': @@ -1111,3 +1111,16 @@ class TestResultStats(unittest.TestResult): def wasSuccessful(self): """Tells whether or not this result was a success""" return self.failed_tests == 0 + + +def get_default_formatter(): + """Obtain the default formatter to write to. + + :return: A file-like object. + """ + formatter = os.getenv("SUBUNIT_FORMATTER") + if formatter: + return os.popen(formatter, "w") + else: + return sys.stdout + |