Skip to content

Commit 001ea4f

Browse files
committed
Add support for equality checking in remoting.Message instances
1 parent bc423c4 commit 001ea4f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

pyamf/remoting/__init__.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ def _get_headers(self):
249249

250250
headers = property(_get_headers)
251251

252+
def __eq__(self, other):
253+
if not isinstance(other, self.__class__):
254+
return False
255+
256+
return self.body == other.body
257+
252258

253259
class Request(Message):
254260
"""
@@ -257,8 +263,8 @@ class Request(Message):
257263
@ivar target: The C{string} target of the request.
258264
"""
259265

260-
def __init__(self, target, body=[], envelope=None):
261-
Message.__init__(self, envelope, body)
266+
def __init__(self, target, body=None, envelope=None):
267+
Message.__init__(self, envelope, body or [])
262268

263269
self.target = target
264270

@@ -270,6 +276,12 @@ def __repr__(self):
270276
type(self).__name__
271277
)
272278

279+
def __eq__(self, other):
280+
if not super(Request, self).__eq__(other):
281+
return False
282+
283+
return self.target == other.target
284+
273285

274286
class Response(Message):
275287
"""
@@ -290,6 +302,12 @@ def __repr__(self):
290302
type(self).__name__
291303
)
292304

305+
def __eq__(self, other):
306+
if not super(Response, self).__eq__(other):
307+
return False
308+
309+
return self.status == other.status
310+
293311

294312
class BaseFault(object):
295313
"""

0 commit comments

Comments
 (0)