Merge lp:~coreygoldberg/selenium-simple-test/testresult-verbosity into lp:selenium-simple-test

Proposed by Corey Goldberg
Status: Rejected
Rejected by: Vincent Ladeuil
Proposed branch: lp:~coreygoldberg/selenium-simple-test/testresult-verbosity
Merge into: lp:selenium-simple-test
Diff against target: 104 lines (+38/-8)
3 files modified
src/sst/result.py (+13/-5)
src/sst/runtests.py (+2/-2)
src/sst/tests/test_result.py (+23/-1)
To merge this branch: bzr merge lp:~coreygoldberg/selenium-simple-test/testresult-verbosity
Reviewer Review Type Date Requested Status
Canonical ISD QA Team Pending
Review via email: mp+170368@code.launchpad.net

Commit message

added an additional verbosity level to TextTestResult

Description of the change

added an additional verbosity level to TextTestResult, allowing finer grained control of output.

this is used to enable/disable timings in output.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

I think we've addressed the original issue now.

Unmerged revisions

420. By Corey Goldberg

added additional verbosity level to texttestresult

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/sst/result.py'
--- src/sst/result.py 2013-06-05 13:15:29 +0000
+++ src/sst/result.py 2013-06-19 14:09:29 +0000
@@ -19,19 +19,25 @@
1919
20import timeit20import timeit
2121
22
23from testtools import testresult22from testtools import testresult
2423
2524
26class TextTestResult(testresult.TextTestResult):25class TextTestResult(testresult.TextTestResult):
27 """A TestResult which outputs activity to a text stream."""26 """A TestResult which outputs activity to a text stream.
2827
28 verbosity levels:
29 1: minimal output
30 2: regular output
31 3: regular output with timings
32
33 """
29 def __init__(self, stream, failfast=False, verbosity=1, timer=None):34 def __init__(self, stream, failfast=False, verbosity=1, timer=None):
30 super(TextTestResult, self).__init__(stream, failfast)35 super(TextTestResult, self).__init__(stream, failfast)
31 if timer is None:36 if timer is None:
32 timer = timeit.default_timer37 timer = timeit.default_timer
33 self.timer = timer38 self.timer = timer
34 self.verbose = verbosity > 139 self.verbose = verbosity > 1
40 self.verbose_timings = verbosity > 2
3541
36 def startTest(self, test):42 def startTest(self, test):
37 if self.verbose:43 if self.verbose:
@@ -41,9 +47,11 @@
41 super(TextTestResult, self).startTest(test)47 super(TextTestResult, self).startTest(test)
4248
43 def stopTest(self, test):49 def stopTest(self, test):
44 if self.verbose:50 if self.verbose_timings:
45 elapsed_time = self.timer() - self.start_time51 elapsed_time = self.timer() - self.start_time
46 self.stream.write(' (%.3f secs)\n' % elapsed_time)52 self.stream.write(' (%.3f secs)' % elapsed_time)
53 if self.verbose:
54 self.stream.write('\n')
47 self.stream.flush()55 self.stream.flush()
48 super(TextTestResult, self).stopTest(test)56 super(TextTestResult, self).stopTest(test)
4957
5058
=== modified file 'src/sst/runtests.py'
--- src/sst/runtests.py 2013-06-05 13:15:29 +0000
+++ src/sst/runtests.py 2013-06-19 14:09:29 +0000
@@ -22,9 +22,9 @@
22import os22import os
23import sys23import sys
2424
25
26import testtools25import testtools
27import testtools.content26import testtools.content
27
28from sst import (28from sst import (
29 browsers,29 browsers,
30 cases,30 cases,
@@ -91,7 +91,7 @@
91 out.write(t.id() + '\n')91 out.write(t.id() + '\n')
92 return 092 return 0
9393
94 text_result = result.TextTestResult(out, failfast=failfast, verbosity=2)94 text_result = result.TextTestResult(out, failfast=failfast, verbosity=3)
95 if report_format == 'xml':95 if report_format == 'xml':
96 results_file = os.path.join(results_directory, 'results.xml')96 results_file = os.path.join(results_directory, 'results.xml')
97 xml_stream = file(results_file, 'wb')97 xml_stream = file(results_file, 'wb')
9898
=== modified file 'src/sst/tests/test_result.py'
--- src/sst/tests/test_result.py 2013-06-18 15:51:48 +0000
+++ src/sst/tests/test_result.py 2013-06-19 14:09:29 +0000
@@ -109,7 +109,29 @@
109 # simplifies matching the expected result109 # simplifies matching the expected result
110 test = get_case(kind)110 test = get_case(kind)
111 out = StringIO()111 out = StringIO()
112 res = result.TextTestResult(out, verbosity=2, timer=lambda: 0.0)112 res = result.TextTestResult(out, verbosity=2)
113 test.run(res)
114 self.assertEquals(expected, res.stream.getvalue())
115
116 def test_pass_output(self):
117 self.assertOutput('''\
118test_pass (sst.tests.test_result.Test) ... OK
119''',
120 'pass')
121
122
123class TestVerboseTimingConsoleOutput(testtools.TestCase):
124
125 def setUp(self):
126 super(TestVerboseTimingConsoleOutput, self).setUp()
127 tests.set_cwd_to_tmp(self)
128
129 def assertOutput(self, expected, kind):
130 # We don't care about timing here so we always return 0 which
131 # simplifies matching the expected result
132 test = get_case(kind)
133 out = StringIO()
134 res = result.TextTestResult(out, verbosity=3, timer=lambda: 0.0)
113 test.run(res)135 test.run(res)
114 self.assertEquals(expected, res.stream.getvalue())136 self.assertEquals(expected, res.stream.getvalue())
115137

Subscribers

People subscribed via source and target branches