diff options
author | Eric Smith <eric@trueblade.com> | 2008-02-18 18:02:34 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2008-02-18 18:02:34 (GMT) |
commit | bc32fee0291cc8ff4085ad805c0f4dca97345863 (patch) | |
tree | a56815ec19a76df767a34f225de50ac00a45486e /Lib/test | |
parent | 5299935be5acefae819bcc08a888a9466747d7cb (diff) | |
download | cpython-bc32fee0291cc8ff4085ad805c0f4dca97345863.zip cpython-bc32fee0291cc8ff4085ad805c0f4dca97345863.tar.gz cpython-bc32fee0291cc8ff4085ad805c0f4dca97345863.tar.bz2 |
Added code to correct combining str and unicode in ''.format(). Added test case.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_unicode.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 26a57cc..ccb9411f 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1088,6 +1088,15 @@ class UnicodeTest( self.assertRaises(ValueError, format, "", "-") self.assertRaises(ValueError, "{0:=s}".format, '') + # test combining string and unicode + self.assertEqual(u"foo{0}".format('bar'), u'foobar') + # This will try to convert the argument from unicode to str, which + # will succeed + self.assertEqual("foo{0}".format(u'bar'), 'foobar') + # This will try to convert the argument from unicode to str, which + # will fail + self.assertRaises(UnicodeEncodeError, "foo{0}".format, u'\u1000bar') + def test_main(): test_support.run_unittest(__name__) |