summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/unicode/test_string_format.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage/tests/unicode/test_string_format.py')
-rw-r--r--pym/portage/tests/unicode/test_string_format.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/pym/portage/tests/unicode/test_string_format.py b/pym/portage/tests/unicode/test_string_format.py
index 95ef9cb12..d2eb81d9a 100644
--- a/pym/portage/tests/unicode/test_string_format.py
+++ b/pym/portage/tests/unicode/test_string_format.py
@@ -4,6 +4,7 @@
import sys
from portage import _encodings, _unicode_decode
+from portage.exception import PortageException
from portage.tests import TestCase
from _emerge.DependencyArg import DependencyArg
@@ -49,3 +50,28 @@ class StringFormatTestCase(TestCase):
# Test the __str__ method which returns encoded bytes in python2
formatted_bytes = "%s" % (dependency_arg,)
self.assertEqual(formatted_bytes, arg_bytes)
+
+ def testPortageException(self):
+
+ self.assertEqual(_encodings['content'], 'utf_8')
+
+ for arg_bytes in self.unicode_strings:
+ arg_unicode = _unicode_decode(arg_bytes, encoding=_encodings['content'])
+ e = PortageException(arg_unicode)
+
+ # Force unicode format string so that __unicode__() is
+ # called in python2.
+ formatted_str = _unicode_decode("%s") % (e,)
+ self.assertEqual(formatted_str, arg_unicode)
+
+ if STR_IS_UNICODE:
+
+ # Test the __str__ method which returns unicode in python3
+ formatted_str = "%s" % (e,)
+ self.assertEqual(formatted_str, arg_unicode)
+
+ else:
+
+ # Test the __str__ method which returns encoded bytes in python2
+ formatted_bytes = "%s" % (e,)
+ self.assertEqual(formatted_bytes, arg_bytes)