Merge lp:~brian.curtin/ubuntuone-dev-tools/py3-exception-message into lp:ubuntuone-dev-tools

Proposed by Brian Curtin on 2012-09-06
Status: Merged
Approved by: Roberto Alsina on 2012-09-06
Approved revision: 97
Merged at revision: 96
Proposed branch: lp:~brian.curtin/ubuntuone-dev-tools/py3-exception-message
Merge into: lp:ubuntuone-dev-tools
Diff against target: 11 lines (+2/-2)
1 file modified
ubuntuone/devtools/services/tests/test_squid.py (+2/-2)
To merge this branch: bzr merge lp:~brian.curtin/ubuntuone-dev-tools/py3-exception-message
Reviewer Review Type Date Requested Status
Roberto Alsina (community) 2012-09-06 Approve on 2012-09-06
Review via email: mp+123151@code.launchpad.net

Commit Message

- Remove usage of Exception.message as it was deprecated and removed from Python 3. Check the exception's "args" attribute for the message.

Description of the Change

Python 2.6 deprecated and Python 3 removed the message attribute of Exception objects, so we need to test for inclusion in the string message via other means.

Exception objects store the message in the args attribute which is a tuple, so testing for our strings inside of the tuple will work. The change tests if any of the args find a match for our string.

To post a comment you must log in.
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/devtools/services/tests/test_squid.py'
2--- ubuntuone/devtools/services/tests/test_squid.py 2012-08-21 20:10:20 +0000
3+++ ubuntuone/devtools/services/tests/test_squid.py 2012-09-06 19:21:20 +0000
4@@ -376,5 +376,5 @@
5 self.patch(self.runner, '_is_squid_running', lambda: False)
6 ex = self.assertRaises(squid.SquidLaunchError,
7 self.runner.start_service)
8- self.assertTrue(out in ex.message)
9- self.assertTrue(err in ex.message)
10+ self.assertTrue(any([out in arg.encode("utf8") for arg in ex.args]))
11+ self.assertTrue(any([err in arg.encode("utf8") for arg in ex.args]))

Subscribers

People subscribed via source and target branches

to all changes: