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: RESOLVED MOVED
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: 2019-12-03 19:18 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

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
Comment 1 GitLab Migration User 2019-12-03 19:18:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/telepathy/telepathy-gabble/issues/15.


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.