Skip to content

Commit 96a58ef

Browse files
committed
Update tests: for 'c' presentation type
Disallow precision and two's complements Also add (missing?) tests do disallow 'c' with #, -, and ' '
1 parent d963a09 commit 96a58ef

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Lib/test/test_long.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -735,12 +735,15 @@ def test__format__(self):
735735
self.assertRaises(ValueError, format, 1234567890, ',b')
736736
self.assertEqual(format(12345, '_b'), '11_0000_0011_1001')
737737

738-
# make sure these are errors
739-
self.assertRaises(ValueError, format, 3, "1.3") # precision disallowed
738+
# make sure these are errors for 'c' presentation type
739+
self.assertRaises(ValueError, format, 3, ".3c") # precision,
740+
self.assertRaises(ValueError, format, 3, "zc") # two's complement,
741+
self.assertRaises(ValueError, format, 3, "#c") # alternate,
740742
self.assertRaises(ValueError, format, 3, "_c") # underscore,
741-
self.assertRaises(ValueError, format, 3, ",c") # comma, and
742-
self.assertRaises(ValueError, format, 3, "+c") # sign not allowed
743-
# with 'c'
743+
self.assertRaises(ValueError, format, 3, ",c") # comma,
744+
self.assertRaises(ValueError, format, 3, "+c") # + sign
745+
self.assertRaises(ValueError, format, 3, "-c") # - sign
746+
self.assertRaises(ValueError, format, 3, " c") # ' ' sign
744747

745748
self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, '_,')
746749
self.assertRaisesRegex(ValueError, 'Cannot specify both', format, 3, ',_')

0 commit comments

Comments
 (0)