~jameinel/subunit/only-genuine-failures

« back to all changes in this revision

Viewing changes to python/subunit/__init__.py

  • Committer: Robert Collins
  • Date: 2010-07-02 00:41:46 UTC
  • Revision ID: robertc@robertcollins.net-20100702004146-ssfg6dlunj89mdh6
Make it clear that BRACKETED parts are utf8 and fix the outputter to do so.

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
except ImportError:
134
134
    raise ImportError ("testtools.testresult.real does not contain "
135
135
        "_StringException, check your version.")
136
 
 
137
 
 
138
 
from testtools.testresult.real import _StringException
 
136
from testtools import testresult
139
137
 
140
138
import chunked, details, test_results
141
139
 
531
529
        self._stream.write(line)
532
530
 
533
531
 
534
 
class TestProtocolClient(unittest.TestResult):
 
532
class TestProtocolClient(testresult.TestResult):
535
533
    """A TestResult which generates a subunit stream for a test run.
536
534
    
537
535
    # Get a TestSuite or TestCase to run
550
548
    """
551
549
 
552
550
    def __init__(self, stream):
553
 
        unittest.TestResult.__init__(self)
 
551
        testresult.TestResult.__init__(self)
554
552
        self._stream = stream
555
553
        _make_stream_binary(stream)
556
554
 
621
619
            self._stream.write(" [\n")
622
620
            # XXX: this needs to be made much stricter, along the lines of
623
621
            # Martin[gz]'s work in testtools. Perhaps subunit can use that?
624
 
            for line in self._exc_info_to_string(error, test).splitlines():
625
 
                self._stream.write("%s\n" % line)
 
622
            for line in self._exc_info_to_unicode(error, test).splitlines():
 
623
                self._stream.write(("%s\n" % line).encode('utf8'))
626
624
        else:
627
625
            self._write_details(details)
628
626
        self._stream.write("]\n")
787
785
 
788
786
    def debug(self):
789
787
        """Run the test without collecting errors in a TestResult"""
790
 
        self._run(unittest.TestResult())
 
788
        self._run(testresult.TestResult())
791
789
 
792
790
    def _run(self, result):
793
791
        protocol = TestProtocolServer(result)
819
817
    """
820
818
 
821
819
    def run(self, result=None):
822
 
        if result is None: result = unittest.TestResult()
 
820
        if result is None: result = testresult.TestResult()
823
821
        run_isolated(unittest.TestSuite, self, result)
824
822
 
825
823
 
1067
1065
        protocol.lostConnection()
1068
1066
 
1069
1067
 
1070
 
class TestResultStats(unittest.TestResult):
 
1068
class TestResultStats(testresult.TestResult):
1071
1069
    """A pyunit TestResult interface implementation for making statistics.
1072
1070
    
1073
1071
    :ivar total_tests: The total tests seen.
1078
1076
 
1079
1077
    def __init__(self, stream):
1080
1078
        """Create a TestResultStats which outputs to stream."""
1081
 
        unittest.TestResult.__init__(self)
 
1079
        testresult.TestResult.__init__(self)
1082
1080
        self._stream = stream
1083
1081
        self.failed_tests = 0
1084
1082
        self.skipped_tests = 0