summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 20:59:24 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-10-18 20:59:24 (GMT)
commit9a90900da59816b4d376c47b94b5513b849db070 (patch)
treeaab54c015837003ae1846d0fd2c7267e390c756c /Lib/test/test_unicode.py
parent0410656b30df532d18a82e5da201501b76e2b1e3 (diff)
downloadcpython-9a90900da59816b4d376c47b94b5513b849db070.zip
cpython-9a90900da59816b4d376c47b94b5513b849db070.tar.gz
cpython-9a90900da59816b4d376c47b94b5513b849db070.tar.bz2
PyUnicode_FromFormatV(): Fix %A format
It was not completly implemented. Add a test.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 5e96ba8..94035ef 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1380,20 +1380,23 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual("{}".format(s), '__str__ overridden')
def test_from_format(self):
- # Ensure that PyUnicode_FromFormat() raises an error for a non-ascii
- # format string.
from _testcapi import format_unicode
# ascii format, non-ascii argument
text = format_unicode(b'ascii\x7f=%U', 'unicode\xe9')
self.assertEqual(text, 'ascii\x7f=unicode\xe9')
- # non-ascii format, ascii argument
+ # non-ascii format, ascii argument: ensure that PyUnicode_FromFormat()
+ # raises an error for a non-ascii format string.
self.assertRaisesRegexp(ValueError,
'^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format '
'string, got a non-ASCII byte: 0xe9$',
format_unicode, b'unicode\xe9=%s', 'ascii')
+ # other tests
+ text = format_unicode(b'%%A:%A', 'abc\xe9\uabcd\U0010ffff')
+ self.assertEqual(text, r"%A:'abc\xe9\uabcd\U0010ffff'")
+
# Test PyUnicode_AsWideChar()
def test_aswidechar(self):
from _testcapi import unicode_aswidechar