Bug 18179 - __repr__ hack for domish.Element doesn't work because assert uses str()
Summary: __repr__ hack for domish.Element doesn't work because assert uses str()
Status: NEW
Alias: None
Product: Telepathy
Classification: Unclassified
Component: gabble (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Telepathy bugs list
QA Contact: Telepathy bugs list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-22 08:20 UTC by Will Thompson
Modified: 2008-10-22 08:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Will Thompson 2008-10-22 08:20:15 UTC
servicetest.py contains the following:

    # hack to ease debugging
    domish.Element.__repr__ = domish.Element.toXml

The intention is that code like:

    assert element['foo'] == bar, element

should produce the stringified xml of element when the assertion fails.  This does not in fact work, as assert uses str() not repr().

Overriding __str__ in the same way yields bizarro exceptions:

Traceback (most recent call last):
  File "/build/buildd/python2.4-2.4.5/Modules/pyexpat.c", line 639, in EndElement
    
  File "/usr/lib/python2.4/site-packages/twisted/words/xish/domish.py", line 780, in _onEndElement
    self.ElementEvent(self.currElem)
  File "/usr/lib/python2.4/site-packages/twisted/words/xish/xmlstream.py", line 106, in onElement
    self.dispatch(element)
  File "/usr/lib/python2.4/site-packages/twisted/words/xish/utility.py", line 316, in dispatch
    callbacklist.callback(obj)
--- <exception caught here> ---
  File "/usr/lib/python2.4/site-packages/twisted/words/xish/utility.py", line 106, in callback
    methodwrapper(*args, **kwargs)
  File "/usr/lib/python2.4/site-packages/twisted/words/xish/utility.py", line 27, in __call__
    self.method(*nargs, **nkwargs)
  File "/home/will/src/Telepathy/telepathy-gabble/tests/twisted/gabbletest.py", line 75, in secondIq
    assert map(str, username) == [self.username]
exceptions.AssertionError: 
Traceback (most recent call last):
  File "/home/will/src/Telepathy/telepathy-gabble/tests/twisted/gabbletest.py", line 316, in exec_test_deferred
    fun(queue, bus, conn, stream)
  File "./muc/test-muc.py", line 16, in test
    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
  File "/home/will/src/Telepathy/telepathy-gabble/tests/twisted/servicetest.py", line 217, in expect
    event = self.wait()
  File "/home/will/src/Telepathy/telepathy-gabble/tests/twisted/servicetest.py", line 286, in wait
    raise TimeoutError
TimeoutError


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.