+ def test_dbus_exception_convert_str_fail(self):
+ """Test that a non-ascii Exception fails to convert to str"""
+ with self.assertRaises(ValueError):
+ e = dbus.exceptions.DBusException(u"bä")
+ print str(e)
Are you sure you get a ValueError here and not a UnicodeEncodeError?
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u'b\xe4\xe4\xe4'
>>> print a
bäää
>>> import dbus.exceptions
>>> x = dbus.exceptions.DBusException(a)
>>> str(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-3: ordinal not in range(128)
One quick question about this test:
+ def test_dbus_ exception_ convert_ str_fail( self): es(ValueError) : .DBusException( u"bä")
+ """Test that a non-ascii Exception fails to convert to str"""
+ with self.assertRais
+ e = dbus.exceptions
+ print str(e)
Are you sure you get a ValueError here and not a UnicodeEncodeError?
Python 2.7.3 (default, Sep 26 2012, 21:51:14) .DBusException( a)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u'b\xe4\xe4\xe4'
>>> print a
bäää
>>> import dbus.exceptions
>>> x = dbus.exceptions
>>> str(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-3: ordinal not in range(128)