| Index: pyautolib/pyauto.py
|
| ===================================================================
|
| --- pyautolib/pyauto.py (revision 146685)
|
| +++ pyautolib/pyauto.py (working copy)
|
| @@ -49,6 +49,7 @@
|
| import urllib
|
|
|
| import pyauto_paths
|
| +from pyauto_utils import GTestTextTestRunner
|
|
|
|
|
| def _LocateBinDirs():
|
| @@ -134,11 +135,15 @@
|
| homepage: the home page. Defaults to "about:blank"
|
| """
|
| # Fetch provided keyword args, or fill in defaults.
|
| + browser_path = kwargs.get('browser_path', None)
|
| clear_profile = kwargs.get('clear_profile', True)
|
| homepage = kwargs.get('homepage', 'about:blank')
|
|
|
| pyautolib.PyUITestBase.__init__(self, clear_profile, homepage)
|
| - self.Initialize(pyautolib.FilePath(self.BrowserPath()))
|
| + if browser_path:
|
| + self.Initialize(pyautolib.FilePath(browser_path))
|
| + else:
|
| + self.Initialize(pyautolib.FilePath(self.BrowserPath()))
|
| unittest.TestCase.__init__(self, methodName)
|
|
|
| # Give all pyauto tests easy access to pprint.PrettyPrinter functions.
|
| @@ -5764,62 +5769,6 @@
|
| 'remote_host.py')], env=env)
|
|
|
|
|
| -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):
|
| - if sys.version_info[:2] <= (2, 4):
|
| - return '%s.%s' % (unittest._strclass(test.__class__),
|
| - test._TestCase__testMethodName)
|
| - return '%s.%s.%s' % (test.__class__.__module__,
|
| - test.__class__.__name__,
|
| - 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 PyAutoTextTestRunner(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()
|
| class Main(object):
|
| """Main program for running PyAuto tests."""
|
| @@ -6123,7 +6072,7 @@
|
| verbosity = 1
|
| if self._options.verbose:
|
| verbosity = 2
|
| - result = PyAutoTextTestRunner(verbosity=verbosity).run(pyauto_suite)
|
| + result = GTestTextTestRunner(verbosity=verbosity).run(pyauto_suite)
|
| del loaded_tests # Need to destroy test cases before the suite
|
| del pyauto_suite
|
| successful = result.wasSuccessful()
|
|
|