Merge lp:~jtatum/mago/pidgin-exception into lp:~mago-contributors/mago/mago-1.0

Proposed by James Tatum
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jtatum/mago/pidgin-exception
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~jtatum/mago/pidgin-exception
Reviewer Review Type Date Requested Status
Ara Pulido Approve
Javier Collado (community) Needs Information
Nagappan Alagappan Approve
Review via email: mp+10774@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Tatum (jtatum) wrote :

If the pidgin suite is invoked and python-pyxmpp or python-msn are not installed, mago crashes. This handles the imports so import errors throw exceptions at test execution time rather than at import time.

Revision history for this message
Nagappan Alagappan (nagappan) wrote :

I think, you can use

if ClientXMPP:
    self.client = ClientXMPP(userid, passwd)
else:
    raise Exception, "pidgin testing requires python-pyxmpp package."

The same can be applied to ClientMSN

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

Hello,

I'm not sure I agree on this change. I would say that the correct way to solve this issue is at the package level, that is, adding those packages as dependencies to mago.

In my opinion, catching ImportError exception should be done if there's an alternative library that could do the same job (for example some xml libraries implement the same ElementTree interface) so the problem can be solved at runtime. If the problem isn't really solved, then the exception should be raised as soon as possible to be able to locate the problem and fix it.

Please let me know what do you think about this.

Best regards,
    Javier

review: Needs Information
Revision history for this message
James Tatum (jtatum) wrote :

Hi Javier,

I agree in principle. Many mago tests already require some configuration of some kind or another and so users should be examining the various README files to see what the prerequisites are. I think the case here is for users that want to use the mago framework but who aren't running all the test suites that are shipping with it. Should the mago package pull in a bunch of libraries that only get used for specific tests? This is a philosophical question.

If the answer is yes, we should probably add the debian directory in to the bzr tree so dependencies can get added as they are added to the source. Mago is not just an ubuntu project, so they need to be documented elsewhere as well.

For what it's worth, without this patch, mago actually crashes when running the suite and does not output a log for the pidgin tests or continue to more tests if you do not have one of the libraries.

Revision history for this message
Rick McBride (rmcbride) wrote :

Hi,

I think for these particular imports that this conditional handling is appropriate. I'd like to be able to run these tests without adding packages that I may not otherwise have installed. The success/failure of a given pidgin installations should not be dependent on me having the MSN or XMPP modules available.

> Hello,
>
> I'm not sure I agree on this change. I would say that the correct way to solve
> this issue is at the package level, that is, adding those packages as
> dependencies to mago.
>
> In my opinion, catching ImportError exception should be done if there's an
> alternative library that could do the same job (for example some xml libraries
> implement the same ElementTree interface) so the problem can be solved at
> runtime. If the problem isn't really solved, then the exception should be
> raised as soon as possible to be able to locate the problem and fix it.
>
> Please let me know what do you think about this.
>
> Best regards,
> Javier

Revision history for this message
Ara Pulido (ara) wrote :

I agree with the change. If included in the packaging it should only be included as a recommends.

If the user does not have it installed, then putting a correct error is better

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'mago/application/pidgin/buddy.py'
--- mago/application/pidgin/buddy.py 2009-06-03 14:22:04 +0000
+++ mago/application/pidgin/buddy.py 2009-08-17 16:11:02 +0000
@@ -2,8 +2,15 @@
22
3import gobject, gtk3import gobject, gtk
44
5from xmpp_utils import ClientXMPP5try:
6from msn_utils import ClientMSN6 from xmpp_utils import ClientXMPP
7except ImportError:
8 ClientXMPP = None
9
10try:
11 from msn_utils import ClientMSN
12except ImportError:
13 ClientMSN = None
714
8class _Buddy(object):15class _Buddy(object):
9 """16 """
@@ -72,7 +79,10 @@
72 def __init__(self, userid, passwd):79 def __init__(self, userid, passwd):
73 80
74 self.account = (userid, passwd)81 self.account = (userid, passwd)
75 self.client = ClientXMPP(userid, passwd)82 try:
83 self.client = ClientXMPP(userid, passwd)
84 except AttributeError:
85 raise Exception, "pidgin testing requires python-pyxmpp package."
76 86
77 def connect(self, register=False, name='', email=''):87 def connect(self, register=False, name='', email=''):
78 def _idle_cb(client):88 def _idle_cb(client):
@@ -138,7 +148,10 @@
138class _BuddyMSN(_Buddy):148class _BuddyMSN(_Buddy):
139 def __init__(self, userid, passwd):149 def __init__(self, userid, passwd):
140 self.account = (userid, passwd)150 self.account = (userid, passwd)
141 self.client = ClientMSN(self.account)151 try:
152 self.client = ClientMSN(self.account)
153 except AttributeError:
154 raise Exception, "pidgin testing requires python-msn package."
142155
143 def connect(self, register=False, name='', email=''):156 def connect(self, register=False, name='', email=''):
144 def _idle_cb(client):157 def _idle_cb(client):

Subscribers

People subscribed via source and target branches

to status/vote changes: