Merge lp:~nataliabidart/u1-test-utils/better-logging-errors into lp:u1-test-utils

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 94
Merged at revision: 95
Proposed branch: lp:~nataliabidart/u1-test-utils/better-logging-errors
Merge into: lp:u1-test-utils
Diff against target: 43 lines (+18/-10)
1 file modified
u1testutils/logging.py (+18/-10)
To merge this branch: bzr merge lp:~nataliabidart/u1-test-utils/better-logging-errors
Reviewer Review Type Date Requested Status
Matias Bordese (community) Approve
Review via email: mp+179818@code.launchpad.net

Commit message

- Better output when memento handler does not have the expected logging.

To post a comment you must log in.
Revision history for this message
Matias Bordese (matiasb) wrote :

LGTM

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (54.8 KiB)

The attempt to merge lp:~nataliabidart/u1-test-utils/better-logging-errors into lp:u1-test-utils failed. Below is the output from the failed tests.

Setting up the virtual environment.
[localhost] local: which virtualenv
[localhost] local: /usr/bin/python /usr/bin/virtualenv --version
[localhost] local: /usr/bin/python /usr/bin/virtualenv --distribute --clear .env
Not deleting .env/bin
New python executable in .env/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
[localhost] local: . /mnt/tarmac/cache/u1-test-utils/trunk/.env/bin/activate && pip install -U -r requirements.txt
Downloading/unpacking bzr+ssh://bazaar.launchpad.net/~bloodearnest/localmail/trunk@36 (from -r requirements.txt (line 9))
  Checking out bzr+ssh://bazaar.launchpad.net/~bloodearnest/localmail/trunk (to revision 36) to /tmp/pip-wdgYcP-build
  Running setup.py egg_info for package from bzr+ssh://bazaar.launchpad.net/~bloodearnest/localmail/trunk@36

Downloading/unpacking bzr+http://bazaar.launchpad.net/~ubuntuone-hackers/payclient/trunk@4 (from -r requirements.txt (line 10))
  Checking out http://bazaar.launchpad.net/~ubuntuone-hackers/payclient/trunk (to revision 4) to /tmp/pip-buVlPx-build
  Running setup.py egg_info for package from bzr+http://bazaar.launchpad.net/~ubuntuone-hackers/payclient/trunk@4

    warning: no previously-included files matching '*.pyc' found anywhere in distribution
Downloading/unpacking bzr+http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk@tag:sst-0.2.4 (from -r requirements.txt (line 11))
  Checking out http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk (to revision tag:sst-0.2.4) to /tmp/pip-PvymRn-build
  Running setup.py egg_info for package from bzr+http://bazaar.launchpad.net/~canonical-isd-qa/selenium-simple-test/trunk@tag:sst-0.2.4

    warning: no files found matching 'testproj.db.original' under directory 'src/testproject'
Downloading/unpacking bzr+http://bazaar.launchpad.net/~canonical-isd-hackers/canonical-identity-provider/ssoclient@3 (from -r requirements.txt (line 12))
  Checking out http://bazaar.launchpad.net/~canonical-isd-hackers/canonical-identity-provider/ssoclient (to revision 3) to /tmp/pip-PbGJce-build
  Running setup.py egg_info for package from bzr+http://bazaar.launchpad.net/~canonical-isd-hackers/canonical-identity-provider/ssoclient@3

Downloading/unpacking beautifulsoup4 (from -r requirements.txt (line 2))
  Running setup.py egg_info for package beautifulsoup4

Downloading/unpacking django==1.4 (from -r requirements.txt (line 3))
  Running setup.py egg_info for package django

Downloading/unpacking mock (from -r requirements.txt (line 4))
  Running setup.py egg_info for package mock

    warning: no files found matching '*.png' under directory 'docs'
    warning: no files found matching '*.css' under directory 'docs'
    warning: no files found matching '*.html' under directory 'docs'
    warning: no files found matching '*.js' under d...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1testutils/logging.py'
2--- u1testutils/logging.py 2013-02-28 16:01:53 +0000
3+++ u1testutils/logging.py 2013-08-12 21:37:16 +0000
4@@ -27,13 +27,16 @@
5
6 def check(self, level, msg, check_traceback=False):
7 """Check that something is logged."""
8+ result = False
9 for rec in self.records:
10- if rec.levelname == level and str(msg) in rec.getMessage():
11- if not check_traceback:
12- return True
13- elif rec.exc_text is not None:
14- return True
15- return False
16+ if rec.levelname == level:
17+ result = str(msg) in rec.getMessage()
18+ if not result and check_traceback:
19+ result = str(msg) in rec.exc_text
20+ if result:
21+ break
22+
23+ return result
24
25 def setUp(self):
26 """Add the memento handler to the root logger."""
27@@ -48,7 +51,12 @@
28 super(LogHandlerTestCase, self).tearDown()
29
30 def assertLogLevelContains(self, level, message, check_traceback=False):
31- # XXX michaeln 2010-08-18 Convert this to use testtools matchers
32- # for much better failure output.
33- self.assertTrue(self.memento_handler.check(
34- level, message, check_traceback=check_traceback))
35+ check = self.memento_handler.check(
36+ level, message, check_traceback=check_traceback)
37+
38+ msg = ('Expected logging message/s could not be found:\n%s\n'
39+ 'Current logging records are:\n%s')
40+ expected = '\t%s: %s' % (level, message)
41+ records = ['\t%s: %s' % (r.levelname, r.getMessage())
42+ for r in self.memento_handler.records]
43+ self.assertTrue(check, msg % (expected, '\n'.join(records)))

Subscribers

People subscribed via source and target branches

to all changes: