Merge lp:~thomir-deactivatedaccount/autopilot/fix-verbose-log-timestamps into lp:autopilot

Proposed by Thomi Richards
Status: Merged
Approved by: Christopher Lee
Approved revision: 106
Merged at revision: 106
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/fix-verbose-log-timestamps
Merge into: lp:autopilot
Diff against target: 59 lines (+23/-4)
2 files modified
autopilot/testcase.py (+4/-3)
autopilot/tests/test_autopilot_functional.py (+19/-1)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/fix-verbose-log-timestamps
Reviewer Review Type Date Requested Status
Christopher Lee (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+137738@code.launchpad.net

Commit message

Verbose log now includes timestamps.

Description of the change

Problem:

The verbose log does not contain any timestamps, while the same content in the file log does. These two should be the same.

Solution:

Fix a typo that was preventing the verbose log from showing timestamps.

Tests:

There's a new test suite that covers this new behavior.

To post a comment you must log in.
106. By Thomi Richards

Make regex more specific.

Revision history for this message
Christopher Lee (veebers) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/testcase.py'
2--- autopilot/testcase.py 2012-10-29 11:10:01 +0000
3+++ autopilot/testcase.py 2012-12-04 02:28:21 +0000
4@@ -99,13 +99,14 @@
5 self._log_buffer = StringIO()
6 root_logger = logging.getLogger()
7 root_logger.setLevel(logging.DEBUG)
8+ log_format = "%(asctime)s %(levelname)s %(module)s:%(lineno)d - %(message)s"
9+ formatter = MyFormatter(log_format)
10 handler = logging.StreamHandler(stream=self._log_buffer)
11- log_format = "%(asctime)s %(levelname)s %(module)s:%(lineno)d - %(message)s"
12- handler.setFormatter(MyFormatter(log_format))
13+ handler.setFormatter(formatter)
14 root_logger.addHandler(handler)
15 if get_log_verbose():
16 stderr_handler = logging.StreamHandler(stream=sys.stderr)
17- handler.setFormatter(MyFormatter(log_format))
18+ stderr_handler.setFormatter(formatter)
19 root_logger.addHandler(stderr_handler)
20
21 #Tear down logging in a cleanUp handler, so it's done after all other
22
23=== modified file 'autopilot/tests/test_autopilot_functional.py'
24--- autopilot/tests/test_autopilot_functional.py 2012-11-14 21:38:12 +0000
25+++ autopilot/tests/test_autopilot_functional.py 2012-12-04 02:28:21 +0000
26@@ -18,7 +18,7 @@
27 from tempfile import mktemp, mkdtemp
28 from testtools.content import Content, text_content
29 from testtools.content_type import ContentType
30-from testtools.matchers import Contains, Equals
31+from testtools.matchers import Contains, Equals, MatchesRegex
32 from textwrap import dedent
33 import re
34
35@@ -382,6 +382,24 @@
36 self.assertThat(code, Equals(0))
37 self.assertThat(error, Contains("Starting test tests.test_simple.SimpleTest.test_simple"))
38
39+ def test_verbose_flag_shows_timestamps(self):
40+ """Verbose log must include timestamps."""
41+ self.create_test_file("test_simple.py", dedent("""\
42+
43+ from autopilot.testcase import AutopilotTestCase
44+
45+
46+ class SimpleTest(AutopilotTestCase):
47+
48+ def test_simple(self):
49+ pass
50+ """
51+ ))
52+
53+ code, output, error = self.run_autopilot(["run", "-v", "tests"])
54+
55+ self.assertThat(error, MatchesRegex("^\d\d:\d\d:\d\d\.\d\d\d"))
56+
57 def test_record_flag_works(self):
58 """Must be able to record videos when the -r flag is present."""
59 self.create_test_file("test_simple.py", dedent("""\

Subscribers

People subscribed via source and target branches