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
=== modified file 'autopilot/testcase.py'
--- autopilot/testcase.py 2012-10-29 11:10:01 +0000
+++ autopilot/testcase.py 2012-12-04 02:28:21 +0000
@@ -99,13 +99,14 @@
99 self._log_buffer = StringIO()99 self._log_buffer = StringIO()
100 root_logger = logging.getLogger()100 root_logger = logging.getLogger()
101 root_logger.setLevel(logging.DEBUG)101 root_logger.setLevel(logging.DEBUG)
102 log_format = "%(asctime)s %(levelname)s %(module)s:%(lineno)d - %(message)s"
103 formatter = MyFormatter(log_format)
102 handler = logging.StreamHandler(stream=self._log_buffer)104 handler = logging.StreamHandler(stream=self._log_buffer)
103 log_format = "%(asctime)s %(levelname)s %(module)s:%(lineno)d - %(message)s"105 handler.setFormatter(formatter)
104 handler.setFormatter(MyFormatter(log_format))
105 root_logger.addHandler(handler)106 root_logger.addHandler(handler)
106 if get_log_verbose():107 if get_log_verbose():
107 stderr_handler = logging.StreamHandler(stream=sys.stderr)108 stderr_handler = logging.StreamHandler(stream=sys.stderr)
108 handler.setFormatter(MyFormatter(log_format))109 stderr_handler.setFormatter(formatter)
109 root_logger.addHandler(stderr_handler)110 root_logger.addHandler(stderr_handler)
110111
111 #Tear down logging in a cleanUp handler, so it's done after all other112 #Tear down logging in a cleanUp handler, so it's done after all other
112113
=== modified file 'autopilot/tests/test_autopilot_functional.py'
--- autopilot/tests/test_autopilot_functional.py 2012-11-14 21:38:12 +0000
+++ autopilot/tests/test_autopilot_functional.py 2012-12-04 02:28:21 +0000
@@ -18,7 +18,7 @@
18from tempfile import mktemp, mkdtemp18from tempfile import mktemp, mkdtemp
19from testtools.content import Content, text_content19from testtools.content import Content, text_content
20from testtools.content_type import ContentType20from testtools.content_type import ContentType
21from testtools.matchers import Contains, Equals21from testtools.matchers import Contains, Equals, MatchesRegex
22from textwrap import dedent22from textwrap import dedent
23import re23import re
2424
@@ -382,6 +382,24 @@
382 self.assertThat(code, Equals(0))382 self.assertThat(code, Equals(0))
383 self.assertThat(error, Contains("Starting test tests.test_simple.SimpleTest.test_simple"))383 self.assertThat(error, Contains("Starting test tests.test_simple.SimpleTest.test_simple"))
384384
385 def test_verbose_flag_shows_timestamps(self):
386 """Verbose log must include timestamps."""
387 self.create_test_file("test_simple.py", dedent("""\
388
389 from autopilot.testcase import AutopilotTestCase
390
391
392 class SimpleTest(AutopilotTestCase):
393
394 def test_simple(self):
395 pass
396 """
397 ))
398
399 code, output, error = self.run_autopilot(["run", "-v", "tests"])
400
401 self.assertThat(error, MatchesRegex("^\d\d:\d\d:\d\d\.\d\d\d"))
402
385 def test_record_flag_works(self):403 def test_record_flag_works(self):
386 """Must be able to record videos when the -r flag is present."""404 """Must be able to record videos when the -r flag is present."""
387 self.create_test_file("test_simple.py", dedent("""\405 self.create_test_file("test_simple.py", dedent("""\

Subscribers

People subscribed via source and target branches