Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36225)

Side by Side Diff: Lib/test/test_types.py

Issue 8931: '#' has no affect with 'c' type
Patch Set: Created 7 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Python/formatter_unicode.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Python test set -- part 6, built-in types 1 # Python test set -- part 6, built-in types
2 2
3 from test.support import run_unittest, run_with_locale 3 from test.support import run_unittest, run_with_locale
4 import unittest 4 import unittest
5 import sys 5 import sys
6 import locale 6 import locale
7 7
8 class TypesTests(unittest.TestCase): 8 class TypesTests(unittest.TestCase):
9 9
10 def test_truth_values(self): 10 def test_truth_values(self):
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 self.assertRaises(ValueError, 3 .__format__, "1.3") 333 self.assertRaises(ValueError, 3 .__format__, "1.3")
334 # sign not allowed with 'c' 334 # sign not allowed with 'c'
335 self.assertRaises(ValueError, 3 .__format__, "+c") 335 self.assertRaises(ValueError, 3 .__format__, "+c")
336 # format spec must be string 336 # format spec must be string
337 self.assertRaises(TypeError, 3 .__format__, None) 337 self.assertRaises(TypeError, 3 .__format__, None)
338 self.assertRaises(TypeError, 3 .__format__, 0) 338 self.assertRaises(TypeError, 3 .__format__, 0)
339 # can't have ',' with 'n' 339 # can't have ',' with 'n'
340 self.assertRaises(ValueError, 3 .__format__, ",n") 340 self.assertRaises(ValueError, 3 .__format__, ",n")
341 # can't have ',' with 'c' 341 # can't have ',' with 'c'
342 self.assertRaises(ValueError, 3 .__format__, ",c") 342 self.assertRaises(ValueError, 3 .__format__, ",c")
343 # can't have '#' with 'c'
344 self.assertRaises(ValueError, 3 .__format__, "#c")
343 345
344 # ensure that only int and float type specifiers work 346 # ensure that only int and float type specifiers work
345 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + 347 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
346 [chr(x) for x in range(ord('A'), ord('Z')+1)]): 348 [chr(x) for x in range(ord('A'), ord('Z')+1)]):
347 if not format_spec in 'bcdoxXeEfFgGn%': 349 if not format_spec in 'bcdoxXeEfFgGn%':
348 self.assertRaises(ValueError, 0 .__format__, format_spec) 350 self.assertRaises(ValueError, 0 .__format__, format_spec)
349 self.assertRaises(ValueError, 1 .__format__, format_spec) 351 self.assertRaises(ValueError, 1 .__format__, format_spec)
350 self.assertRaises(ValueError, (-1) .__format__, format_spec) 352 self.assertRaises(ValueError, (-1) .__format__, format_spec)
351 353
352 # ensure that float type specifiers work; format converts 354 # ensure that float type specifiers work; format converts
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 def test_internal_sizes(self): 569 def test_internal_sizes(self):
568 self.assertGreater(object.__basicsize__, 0) 570 self.assertGreater(object.__basicsize__, 0)
569 self.assertGreater(tuple.__itemsize__, 0) 571 self.assertGreater(tuple.__itemsize__, 0)
570 572
571 573
572 def test_main(): 574 def test_main():
573 run_unittest(TypesTests) 575 run_unittest(TypesTests)
574 576
575 if __name__ == '__main__': 577 if __name__ == '__main__':
576 test_main() 578 test_main()
OLDNEW
« no previous file with comments | « no previous file | Python/formatter_unicode.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+