Skip to content

Commit b278c72

Browse files
authored
gh-119780: Adjust exception messages in Lib/test/test_format.py (GH-119781)
Mismatches were just output to the stdout, without making the test failing.
1 parent 010aaa3 commit b278c72

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Lib/test/test_format.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ def test_str_format(self):
304304
test_exc('%c', sys.maxunicode+1, OverflowError,
305305
"%c arg not in range(0x110000)")
306306
#test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)")
307-
test_exc('%c', 3.14, TypeError, "%c requires int or char")
308-
test_exc('%c', 'ab', TypeError, "%c requires int or char")
309-
test_exc('%c', b'x', TypeError, "%c requires int or char")
307+
test_exc('%c', 3.14, TypeError, "%c requires an int or a unicode character, not float")
308+
test_exc('%c', 'ab', TypeError, "%c requires an int or a unicode character, not a string of length 2")
309+
test_exc('%c', b'x', TypeError, "%c requires an int or a unicode character, not bytes")
310310

311311
if maxsize == 2**31-1:
312312
# crashes 2.2.1 and earlier:
@@ -370,11 +370,11 @@ def __bytes__(self):
370370
test_exc(b"%c", 2**128, OverflowError,
371371
"%c arg not in range(256)")
372372
test_exc(b"%c", b"Za", TypeError,
373-
"%c requires an integer in range(256) or a single byte")
373+
"%c requires an integer in range(256) or a single byte, not a bytes object of length 2")
374374
test_exc(b"%c", "Y", TypeError,
375-
"%c requires an integer in range(256) or a single byte")
375+
"%c requires an integer in range(256) or a single byte, not str")
376376
test_exc(b"%c", 3.14, TypeError,
377-
"%c requires an integer in range(256) or a single byte")
377+
"%c requires an integer in range(256) or a single byte, not float")
378378
test_exc(b"%b", "Xc", TypeError,
379379
"%b requires a bytes-like object, "
380380
"or an object that implements __bytes__, not 'str'")

0 commit comments

Comments
 (0)