summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_format.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-06-11 18:37:52 (GMT)
committerGeorg Brandl <georg@python.org>2008-06-11 18:37:52 (GMT)
commit559e5d7f4d1155e95fb6f925c927a263f9196935 (patch)
tree4688423e81e9ffed7a5b2c87c50b55419e8e885a /Lib/test/test_format.py
parentea6d58d9d3033436b52e84960b9571525a4f5412 (diff)
downloadcpython-559e5d7f4d1155e95fb6f925c927a263f9196935.zip
cpython-559e5d7f4d1155e95fb6f925c927a263f9196935.tar.gz
cpython-559e5d7f4d1155e95fb6f925c927a263f9196935.tar.bz2
#2630: Implement PEP 3138.
The repr() of a string now contains printable Unicode characters unescaped. The new ascii() builtin can be used to get a repr() with only ASCII characters in it. PEP and patch were written by Atsuo Ishimoto.
Diffstat (limited to 'Lib/test/test_format.py')
-rw-r--r--Lib/test/test_format.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index fb91475..8bc47d4 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -216,6 +216,8 @@ class FormatTest(unittest.TestCase):
testformat("%o", 0o42, "42")
testformat("%o", -0o42, "-42")
testformat("%o", float(0o42), "42")
+ testformat("%r", "\u0370", "'\u0370'")
+ testformat("%a", "\u0370", "'\\u0370'")
# Test exception for unknown format characters
if verbose:
print('Testing exceptions')
@@ -235,8 +237,8 @@ class FormatTest(unittest.TestCase):
raise
else:
raise TestFailed('did not get expected exception: %s' % excmsg)
- test_exc('abc %a', 1, ValueError,
- "unsupported format character 'a' (0x61) at index 5")
+ test_exc('abc %b', 1, ValueError,
+ "unsupported format character 'b' (0x62) at index 5")
#test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
# "unsupported format character '?' (0x3000) at index 5")
test_exc('%d', '1', TypeError, "%d format: a number is required, not str")