Merge lp:~benji/launchpad/bug-992692 into lp:launchpad

Proposed by Benji York
Status: Merged
Approved by: Benji York
Approved revision: no longer in the source branch.
Merged at revision: 15198
Proposed branch: lp:~benji/launchpad/bug-992692
Merge into: lp:launchpad
Diff against target: 15 lines (+5/-0)
1 file modified
lib/lp/testing/__init__.py (+5/-0)
To merge this branch: bzr merge lp:~benji/launchpad/bug-992692
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+104599@code.launchpad.net

Commit message

clear out any existing log handlers at the start of each test case so tests that add handlers don't effect those that depend on no handlers being registered.

Description of the change

Several tests add log handlers that transmute log entries into OOPSes. Some other tests then log things and expect there to be no OOPSes and generate test failures when that expectation is not met.

This branch clears out any existing handlers at the start of each test case.

The full test suite has been run with this change in place and all tests passed.

The "make lint" report is clean.

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good. Thanks, Benji.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/testing/__init__.py'
2--- lib/lp/testing/__init__.py 2012-04-25 13:45:25 +0000
3+++ lib/lp/testing/__init__.py 2012-05-03 19:14:22 +0000
4@@ -647,6 +647,11 @@
5 self.addCleanup(
6 self.attachLibrarianLog,
7 LibrarianLayer.librarian_fixture)
8+ # Remove all log handlers, tests should not depend on global logging
9+ # config but should make their own config instead.
10+ logger = logging.getLogger()
11+ for handler in logger.handlers:
12+ logger.removeHandler(handler)
13
14 def assertStatementCount(self, expected_count, function, *args, **kwargs):
15 """Assert that the expected number of SQL statements occurred.