diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-10-16 17:52:22 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2012-10-16 17:52:22 +0100 |
commit | 83615efbed565a689008b00a4ac82fc0fc4e5603 (patch) | |
tree | e1a1227aa08007569061c4491b88da0e08bec9d0 | |
parent | 09b540bd55fb2fca14d4df7e0c520b8ba0ce4646 (diff) |
Skip test_dbus_exception_convert_str_fail under unusual default encodings
This would actually work fine if the default encoding was UTF-8 or
Latin-1 or something.
-rw-r--r-- | test/test-exception-py2.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test/test-exception-py2.py b/test/test-exception-py2.py index 3a8026c..98a6cd9 100644 --- a/test/test-exception-py2.py +++ b/test/test-exception-py2.py @@ -1,6 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +import sys import unittest import dbus @@ -34,9 +35,13 @@ class DBusExceptionTestCase(unittest.TestCase): 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) + if sys.getdefaultencoding() == 'ascii': + with self.assertRaises(UnicodeEncodeError): + e = dbus.exceptions.DBusException(u"bä") + print str(e) + else: + self.skipTest("you're using a weird non-ascii " + "sys.getdefaultencoding()") def test_dbus_exception_convert_unicode(self): """Test that converting a DBusEception to unicode works""" |