Revert 56951 - Produce gtest style output with pyauto.

(Breaks on py2.4 on win)

This makes it easy to digest pass/fail status for individual tests ("OK" is more discoverable than '.' in the output log). And makes it easier to associate LOG messages from chrome with the individual tests triggering them.

BUG=42148

Review URL: http://codereview.chromium.org/3191014

TBR=nirnimesh@chromium.org
Review URL: http://codereview.chromium.org/3126027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56990 0039d316-1c4b-4281-b951-d872f2087c98
parent 5606d30e
...@@ -1348,57 +1348,6 @@ class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): ...@@ -1348,57 +1348,6 @@ class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite):
pyautolib.PyUITestSuiteBase.__del__(self) pyautolib.PyUITestSuiteBase.__del__(self)
class _GTestTextTestResult(unittest._TextTestResult):
"""A test result class that can print formatted text results to a stream.
Results printed in conformance with gtest output format, like:
[ RUN ] autofill.AutoFillTest.testAutofillInvalid: "test desc."
[ OK ] autofill.AutoFillTest.testAutofillInvalid
[ RUN ] autofill.AutoFillTest.testFillProfile: "test desc."
[ OK ] autofill.AutoFillTest.testFillProfile
[ RUN ] autofill.AutoFillTest.testFillProfileCrazyCharacters: "Test."
[ OK ] autofill.AutoFillTest.testFillProfileCrazyCharacters
"""
def __init__(self, stream, descriptions, verbosity):
unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
def _GetTestURI(self, test):
return '%s.%s' % (unittest._strclass(test.__class__), test._testMethodName)
def getDescription(self, test):
return '%s: "%s"' % (self._GetTestURI(test), test.shortDescription())
def startTest(self, test):
unittest.TestResult.startTest(self, test)
self.stream.writeln('[ RUN ] %s' % self.getDescription(test))
def addSuccess(self, test):
unittest.TestResult.addSuccess(self, test)
self.stream.writeln('[ OK ] %s' % self._GetTestURI(test))
def addError(self, test, err):
unittest.TestResult.addError(self, test, err)
self.stream.writeln('[ ERROR ] %s' % self._GetTestURI(test))
def addFailure(self, test, err):
unittest.TestResult.addFailure(self, test, err)
self.stream.writeln('[ FAILED ] %s' % self._GetTestURI(test))
class PyAutoTextTestRuner(unittest.TextTestRunner):
"""Test Runner for PyAuto tests that displays results in textual format.
Results are displayed in conformance with gtest output.
"""
def __init__(self, verbosity=1):
unittest.TextTestRunner.__init__(self,
stream=sys.stderr,
verbosity=verbosity)
def _makeResult(self):
return _GTestTextTestResult(self.stream, self.descriptions, self.verbosity)
# Implementation inspired from unittest.main() # Implementation inspired from unittest.main()
class Main(object): class Main(object):
"""Main program for running PyAuto tests.""" """Main program for running PyAuto tests."""
...@@ -1626,7 +1575,7 @@ class Main(object): ...@@ -1626,7 +1575,7 @@ class Main(object):
verbosity = 1 verbosity = 1
if self._options.verbose: if self._options.verbose:
verbosity = 2 verbosity = 2
result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite)
del loaded_tests # Need to destroy test cases before the suite del loaded_tests # Need to destroy test cases before the suite
del pyauto_suite del pyauto_suite
sys.exit(not result.wasSuccessful()) sys.exit(not result.wasSuccessful())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment