Merge lp:~flacoste/lazr.restful/better-asserts into lp:lazr.restful

Proposed by Francis J. Lacoste
Status: Merged
Approved by: Barry Warsaw
Approved revision: 36
Merged at revision: not available
Proposed branch: lp:~flacoste/lazr.restful/better-asserts
Merge into: lp:lazr.restful
Diff against target: None lines
To merge this branch: bzr merge lp:~flacoste/lazr.restful/better-asserts
Reviewer Review Type Date Requested Status
Barry Warsaw Approve
Review via email: mp+6096@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Please review my branch:

   bzr+ssh://bazaar.launchpad.net/~flacoste/lazr.restful/better-asserts

revision 36.

This adds an assert to catch errors when the adapter cannot be found. This
lead previously to fail in the other assert where i expanded the error
message.

This will help debug things when there are errors in the annotations.

--
Francis J. Lacoste
<email address hidden>

Revision history for this message
Barry Warsaw (barry) wrote :

I've actually looked at this code recently. These are good helpful additions I think!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/restful/_resource.py'
2--- src/lazr/restful/_resource.py 2009-04-24 15:28:26 +0000
3+++ src/lazr/restful/_resource.py 2009-05-01 17:52:00 +0000
4@@ -1675,6 +1675,8 @@
5 """
6 entry_class = getGlobalSiteManager().adapters.lookup(
7 (entry_interface,), IEntry)
8+ assert entry_class is not None, (
9+ "No IEntry adapter found for %s." % entry_interface.__name__)
10 return EntryAdapterUtility(entry_class)
11
12 @classmethod
13@@ -1704,9 +1706,11 @@
14 interfaces = implementedBy(self.entry_class)
15 entry_ifaces = [interface for interface in interfaces
16 if interface.extends(IEntry)]
17- assert len(entry_ifaces) == 1, ("There must be one and only one "
18- "IEntry implementation "
19- "for %s" % self.entry_class)
20+ assert len(entry_ifaces) == 1, (
21+ "There must be one and only one IEntry implementation "
22+ "for %s, found %s" % (
23+ self.entry_class,
24+ ", ".join(interface.__name__ for interface in entry_ifaces)))
25 return entry_ifaces[0]
26
27 @property

Subscribers

People subscribed via source and target branches