Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 3126027: Revert 56951 - Produce gtest style output with pyauto.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """PyAuto: Python Interface to Chromium's Automation Proxy. 7 """PyAuto: Python Interface to Chromium's Automation Proxy.
8 8
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. 9 PyAuto uses swig to expose Automation Proxy interfaces to Python.
10 For complete documentation on the functionality available, 10 For complete documentation on the functionality available,
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 1341
1342 def __del__(self): 1342 def __del__(self):
1343 # python unittest module is setup such that the suite gets deleted before 1343 # python unittest module is setup such that the suite gets deleted before
1344 # the test cases, which is odd because our test cases depend on 1344 # the test cases, which is odd because our test cases depend on
1345 # initializtions like exitmanager, autorelease pool provided by the 1345 # initializtions like exitmanager, autorelease pool provided by the
1346 # suite. Forcibly delete the test cases before the suite. 1346 # suite. Forcibly delete the test cases before the suite.
1347 del self._tests 1347 del self._tests
1348 pyautolib.PyUITestSuiteBase.__del__(self) 1348 pyautolib.PyUITestSuiteBase.__del__(self)
1349 1349
1350 1350
1351 class _GTestTextTestResult(unittest._TextTestResult):
1352 """A test result class that can print formatted text results to a stream.
1353
1354 Results printed in conformance with gtest output format, like:
1355 [ RUN ] autofill.AutoFillTest.testAutofillInvalid: "test desc."
1356 [ OK ] autofill.AutoFillTest.testAutofillInvalid
1357 [ RUN ] autofill.AutoFillTest.testFillProfile: "test desc."
1358 [ OK ] autofill.AutoFillTest.testFillProfile
1359 [ RUN ] autofill.AutoFillTest.testFillProfileCrazyCharacters: "Test."
1360 [ OK ] autofill.AutoFillTest.testFillProfileCrazyCharacters
1361 """
1362 def __init__(self, stream, descriptions, verbosity):
1363 unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
1364
1365 def _GetTestURI(self, test):
1366 return '%s.%s' % (unittest._strclass(test.__class__), test._testMethodName)
1367
1368 def getDescription(self, test):
1369 return '%s: "%s"' % (self._GetTestURI(test), test.shortDescription())
1370
1371 def startTest(self, test):
1372 unittest.TestResult.startTest(self, test)
1373 self.stream.writeln('[ RUN ] %s' % self.getDescription(test))
1374
1375 def addSuccess(self, test):
1376 unittest.TestResult.addSuccess(self, test)
1377 self.stream.writeln('[ OK ] %s' % self._GetTestURI(test))
1378
1379 def addError(self, test, err):
1380 unittest.TestResult.addError(self, test, err)
1381 self.stream.writeln('[ ERROR ] %s' % self._GetTestURI(test))
1382
1383 def addFailure(self, test, err):
1384 unittest.TestResult.addFailure(self, test, err)
1385 self.stream.writeln('[ FAILED ] %s' % self._GetTestURI(test))
1386
1387
1388 class PyAutoTextTestRuner(unittest.TextTestRunner):
1389 """Test Runner for PyAuto tests that displays results in textual format.
1390
1391 Results are displayed in conformance with gtest output.
1392 """
1393 def __init__(self, verbosity=1):
1394 unittest.TextTestRunner.__init__(self,
1395 stream=sys.stderr,
1396 verbosity=verbosity)
1397
1398 def _makeResult(self):
1399 return _GTestTextTestResult(self.stream, self.descriptions, self.verbosity)
1400
1401
1402 # Implementation inspired from unittest.main() 1351 # Implementation inspired from unittest.main()
1403 class Main(object): 1352 class Main(object):
1404 """Main program for running PyAuto tests.""" 1353 """Main program for running PyAuto tests."""
1405 1354
1406 _options, _args = None, None 1355 _options, _args = None, None
1407 _tests_filename = 'PYAUTO_TESTS' 1356 _tests_filename = 'PYAUTO_TESTS'
1408 _platform_map = { 1357 _platform_map = {
1409 'win32': 'win', 1358 'win32': 'win',
1410 'darwin': 'mac', 1359 'darwin': 'mac',
1411 'linux2': 'linux', 1360 'linux2': 'linux',
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 # read values back out. 1568 # read values back out.
1620 chrome_flags += ' --dom-automation' 1569 chrome_flags += ' --dom-automation'
1621 1570
1622 suite_args.append('--extra-chrome-flags=%s' % chrome_flags) 1571 suite_args.append('--extra-chrome-flags=%s' % chrome_flags)
1623 pyauto_suite = PyUITestSuite(suite_args) 1572 pyauto_suite = PyUITestSuite(suite_args)
1624 loaded_tests = self._LoadTests(self._args) 1573 loaded_tests = self._LoadTests(self._args)
1625 pyauto_suite.addTests(loaded_tests) 1574 pyauto_suite.addTests(loaded_tests)
1626 verbosity = 1 1575 verbosity = 1
1627 if self._options.verbose: 1576 if self._options.verbose:
1628 verbosity = 2 1577 verbosity = 2
1629 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 1578 result = unittest.TextTestRunner(verbosity=verbosity).run(pyauto_suite)
1630 del loaded_tests # Need to destroy test cases before the suite 1579 del loaded_tests # Need to destroy test cases before the suite
1631 del pyauto_suite 1580 del pyauto_suite
1632 sys.exit(not result.wasSuccessful()) 1581 sys.exit(not result.wasSuccessful())
1633 1582
1634 1583
1635 if __name__ == '__main__': 1584 if __name__ == '__main__':
1636 Main() 1585 Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698