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
1=== modified file 'src/sst/result.py'
2--- src/sst/result.py 2013-06-05 13:15:29 +0000
3+++ src/sst/result.py 2013-06-19 14:09:29 +0000
4@@ -19,19 +19,25 @@
5
6 import timeit
7
8-
9 from testtools import testresult
10
11
12 class TextTestResult(testresult.TextTestResult):
13- """A TestResult which outputs activity to a text stream."""
14-
15+ """A TestResult which outputs activity to a text stream.
16+
17+ verbosity levels:
18+ 1: minimal output
19+ 2: regular output
20+ 3: regular output with timings
21+
22+ """
23 def __init__(self, stream, failfast=False, verbosity=1, timer=None):
24 super(TextTestResult, self).__init__(stream, failfast)
25 if timer is None:
26 timer = timeit.default_timer
27 self.timer = timer
28 self.verbose = verbosity > 1
29+ self.verbose_timings = verbosity > 2
30
31 def startTest(self, test):
32 if self.verbose:
33@@ -41,9 +47,11 @@
34 super(TextTestResult, self).startTest(test)
35
36 def stopTest(self, test):
37- if self.verbose:
38+ if self.verbose_timings:
39 elapsed_time = self.timer() - self.start_time
40- self.stream.write(' (%.3f secs)\n' % elapsed_time)
41+ self.stream.write(' (%.3f secs)' % elapsed_time)
42+ if self.verbose:
43+ self.stream.write('\n')
44 self.stream.flush()
45 super(TextTestResult, self).stopTest(test)
46
47
48=== modified file 'src/sst/runtests.py'
49--- src/sst/runtests.py 2013-06-05 13:15:29 +0000
50+++ src/sst/runtests.py 2013-06-19 14:09:29 +0000
51@@ -22,9 +22,9 @@
52 import os
53 import sys
54
55-
56 import testtools
57 import testtools.content
58+
59 from sst import (
60 browsers,
61 cases,
62@@ -91,7 +91,7 @@
63 out.write(t.id() + '\n')
64 return 0
65
66- text_result = result.TextTestResult(out, failfast=failfast, verbosity=2)
67+ text_result = result.TextTestResult(out, failfast=failfast, verbosity=3)
68 if report_format == 'xml':
69 results_file = os.path.join(results_directory, 'results.xml')
70 xml_stream = file(results_file, 'wb')
71
72=== modified file 'src/sst/tests/test_result.py'
73--- src/sst/tests/test_result.py 2013-06-18 15:51:48 +0000
74+++ src/sst/tests/test_result.py 2013-06-19 14:09:29 +0000
75@@ -109,7 +109,29 @@
76 # simplifies matching the expected result
77 test = get_case(kind)
78 out = StringIO()
79- res = result.TextTestResult(out, verbosity=2, timer=lambda: 0.0)
80+ res = result.TextTestResult(out, verbosity=2)
81+ test.run(res)
82+ self.assertEquals(expected, res.stream.getvalue())
83+
84+ def test_pass_output(self):
85+ self.assertOutput('''\
86+test_pass (sst.tests.test_result.Test) ... OK
87+''',
88+ 'pass')
89+
90+
91+class TestVerboseTimingConsoleOutput(testtools.TestCase):
92+
93+ def setUp(self):
94+ super(TestVerboseTimingConsoleOutput, self).setUp()
95+ tests.set_cwd_to_tmp(self)
96+
97+ def assertOutput(self, expected, kind):
98+ # We don't care about timing here so we always return 0 which
99+ # simplifies matching the expected result
100+ test = get_case(kind)
101+ out = StringIO()
102+ res = result.TextTestResult(out, verbosity=3, timer=lambda: 0.0)
103 test.run(res)
104 self.assertEquals(expected, res.stream.getvalue())
105

Subscribers

People subscribed via source and target branches