summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_format.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-07-28 16:44:23 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-07-28 16:44:23 (GMT)
commit88fe4ff5a962dfd2e1889c5d5c1a04c00b8264ba (patch)
tree05d2e9b3c79646242af9f55ec93fb31d81ae7d17 /Lib/test/test_format.py
parent673c0a2247e6c1bacdd87df1bc82e8b042933f4b (diff)
downloadcpython-88fe4ff5a962dfd2e1889c5d5c1a04c00b8264ba.zip
cpython-88fe4ff5a962dfd2e1889c5d5c1a04c00b8264ba.tar.gz
cpython-88fe4ff5a962dfd2e1889c5d5c1a04c00b8264ba.tar.bz2
Fix the problem of not raising a TypeError exception when doing:
'%g' % '1' '%d' % '1' Add a test for these conditions Fix the test so that if not exception is raise, this is a failure
Diffstat (limited to 'Lib/test/test_format.py')
-rw-r--r--Lib/test/test_format.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index def8e65..3013a08 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -1,4 +1,4 @@
-from test.test_support import verbose, have_unicode
+from test.test_support import verbose, have_unicode, TestFailed
import sys
# test string formatting operator (I am not sure if this is being tested
@@ -210,9 +210,15 @@ def test_exc(formatstr, args, exception, excmsg):
if verbose: print 'no'
print 'Unexpected exception'
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")
if have_unicode:
test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
"unsupported format character '?' (0x3000) at index 5")
+
+test_exc('%d', '1', TypeError, "int argument required")
+test_exc('%g', '1', TypeError, "float argument required")
+