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

Side by Side Diff: chrome/test/webdriver/gtest_text_test_runner.py

Issue 7331004: Move chromedriver tests to test subdirectory. Add script to run all chromedriver (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: ... Created 9 years, 5 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 | « chrome/test/webdriver/chromedriver_tests.py ('k') | chrome/test/webdriver/iframe_src.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """A |unittest.TextTestRunner| that displays results like Google Test."""
8
9 import sys
10 import unittest
11
12
13 class _GTestTextTestResult(unittest._TextTestResult):
14 """A test result class that can print formatted text results to a stream.
15
16 Results printed in conformance with gtest output format, like:
17 [ RUN ] autofill.AutofillTest.testAutofillInvalid: "test desc."
18 [ OK ] autofill.AutofillTest.testAutofillInvalid
19 [ RUN ] autofill.AutofillTest.testFillProfile: "test desc."
20 [ OK ] autofill.AutofillTest.testFillProfile
21 [ RUN ] autofill.AutofillTest.testFillProfileCrazyCharacters: "Test."
22 [ OK ] autofill.AutofillTest.testFillProfileCrazyCharacters
23 """
24 def __init__(self, stream, descriptions, verbosity):
25 unittest._TextTestResult.__init__(self, stream, descriptions, verbosity)
26
27 def _GetTestURI(self, test):
28 if sys.version_info[:2] <= (2, 4):
29 return '%s.%s' % (unittest._strclass(test.__class__),
30 test._TestCase__testMethodName)
31 return '%s.%s' % (unittest._strclass(test.__class__), test._testMethodName)
32
33 def getDescription(self, test):
34 return '%s: "%s"' % (self._GetTestURI(test), test.shortDescription())
35
36 def startTest(self, test):
37 unittest.TestResult.startTest(self, test)
38 self.stream.writeln('[ RUN ] %s' % self.getDescription(test))
39
40 def addSuccess(self, test):
41 unittest.TestResult.addSuccess(self, test)
42 self.stream.writeln('[ OK ] %s' % self._GetTestURI(test))
43
44 def addError(self, test, err):
45 unittest.TestResult.addError(self, test, err)
46 self.stream.writeln('[ ERROR ] %s' % self._GetTestURI(test))
47
48 def addFailure(self, test, err):
49 unittest.TestResult.addFailure(self, test, err)
50 self.stream.writeln('[ FAILED ] %s' % self._GetTestURI(test))
51
52
53 class GTestTextTestRunner(unittest.TextTestRunner):
54 """Test runner for python unittests that displays results in textual format.
55
56 Results are displayed in conformance with gtest output.
57 """
58 def __init__(self, verbosity=1):
59 unittest.TextTestRunner.__init__(self,
60 stream=sys.stderr,
61 verbosity=verbosity)
62
63 def _makeResult(self):
64 return _GTestTextTestResult(self.stream, self.descriptions, self.verbosity)
OLDNEW
« no previous file with comments | « chrome/test/webdriver/chromedriver_tests.py ('k') | chrome/test/webdriver/iframe_src.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698