From 83615efbed565a689008b00a4ac82fc0fc4e5603 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Oct 2012 17:52:22 +0100 Subject: 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. --- test/test-exception-py2.py | 11 ++++++++--- 1 file 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""" -- cgit v1.2.1