1# tests for errors in {} format string
2
3try:
4    '{0:0}'.format('zzz')
5except (ValueError):
6    print('ValueError')
7
8try:
9    '{1:}'.format(1)
10except IndexError:
11    print('IndexError')
12
13try:
14    '}'.format('zzzz')
15except ValueError:
16    print('ValueError')
17
18# end of format parsing conversion specifier
19try:
20    '{!'.format('a')
21except ValueError:
22    print('ValueError')
23
24# unknown conversion specifier
25try:
26    'abc{!d}'.format('1')
27except ValueError:
28    print('ValueError')
29
30try:
31    '{abc'.format('zzzz')
32except ValueError:
33    print('ValueError')
34
35# expected ':' after specifier
36try:
37    '{!s :}'.format(2)
38except ValueError:
39    print('ValueError')
40
41try:
42    '{}{0}'.format(1, 2)
43except ValueError:
44    print('ValueError')
45
46try:
47    '{1:}'.format(1)
48except IndexError:
49    print('IndexError')
50
51try:
52    '{ 0 :*^10}'.format(12)
53except KeyError:
54    print('KeyError')
55
56try:
57    '{0}{}'.format(1)
58except ValueError:
59    print('ValueError')
60
61try:
62    '{}{}'.format(1)
63except IndexError:
64    print('IndexError')
65
66try:
67    '{0:+s}'.format('1')
68except ValueError:
69    print('ValueError')
70
71try:
72    '{0:+c}'.format(1)
73except ValueError:
74    print('ValueError')
75
76try:
77    '{0:s}'.format(1)
78except ValueError:
79    print('ValueError')
80
81try:
82    '{:*"1"}'.format('zz')
83except ValueError:
84    print('ValueError')
85
86# unknown format code for str arg
87try:
88    '{:X}'.format('zz')
89except ValueError:
90    print('ValueError')
91