@@ -1326,6 +1326,8 @@ def test_format_e_presentation_type(self):
13261326 (F ('1234567.123456' ), '.5_e' , '1.234_57e+06' ),
13271327 # z flag is legal, but never makes a difference to the output
13281328 (F (- 1 , 7 ** 100 ), 'z.6e' , '-3.091690e-85' ),
1329+ # fill and/or alignment with zero padding
1330+ (F (2 , 3 ), '=010e' , format (float (F (2 , 3 )), '=010e' )),
13291331 ]
13301332 for fraction , spec , expected in testcases :
13311333 with self .subTest (fraction = fraction , spec = spec ):
@@ -1525,6 +1527,23 @@ def test_format_f_presentation_type(self):
15251527 (F (151 , 1000 ), '.1f' , '0.2' ),
15261528 (F (22 , 7 ), '.02f' , '3.14' ), # issue gh-130662
15271529 (F (22 , 7 ), '005.02f' , '03.14' ),
1530+ # fill and/or alignment with zero padding
1531+ (F (2 , 3 ), 'X>010f' , format (float (F (2 , 3 )), 'X>010f' )),
1532+ (F (2 , 3 ), 'X<010f' , format (float (F (2 , 3 )), 'X<010f' )),
1533+ (F (2 , 3 ), 'X^010f' , format (float (F (2 , 3 )), 'X^010f' )),
1534+ (F (2 , 3 ), 'X=010f' , format (float (F (2 , 3 )), 'X=010f' )),
1535+ (F (2 , 3 ), '0>010f' , format (float (F (2 , 3 )), '0>010f' )),
1536+ (F (2 , 3 ), '0<010f' , format (float (F (2 , 3 )), '0<010f' )),
1537+ (F (2 , 3 ), '0^010f' , format (float (F (2 , 3 )), '0^010f' )),
1538+ (F (2 , 3 ), '0=010f' , format (float (F (2 , 3 )), '0=010f' )),
1539+ (F (2 , 3 ), '>010f' , format (float (F (2 , 3 )), '>010f' )),
1540+ (F (2 , 3 ), '<010f' , format (float (F (2 , 3 )), '<010f' )),
1541+ (F (2 , 3 ), '^010f' , format (float (F (2 , 3 )), '^010f' )),
1542+ (F (2 , 3 ), '=010e' , format (float (F (2 , 3 )), '=010e' )),
1543+ (F (2 , 3 ), '=010f' , format (float (F (2 , 3 )), '=010f' )),
1544+ (F (2 , 3 ), '>00.2f' , format (float (F (2 , 3 )), '>00.2f' )),
1545+ (F (2 , 3 ), '>00f' , format (float (F (2 , 3 )), '>00f' )),
1546+ (F (2 , 3 ), '=010%' , format (float (F (2 , 3 )), '=010%' )),
15281547 ]
15291548 for fraction , spec , expected in testcases :
15301549 with self .subTest (fraction = fraction , spec = spec ):
@@ -1593,6 +1612,8 @@ def test_format_g_presentation_type(self):
15931612 (F (2 ** 64 ), '_.25g' , '18_446_744_073_709_551_616' ),
15941613 # As with 'e' format, z flag is legal, but has no effect
15951614 (F (- 1 , 7 ** 100 ), 'zg' , '-3.09169e-85' ),
1615+ # fill and/or alignment with zero padding
1616+ (F (2 , 3 ), '=010g' , format (float (F (2 , 3 )), '=010g' )),
15961617 ]
15971618 for fraction , spec , expected in testcases :
15981619 with self .subTest (fraction = fraction , spec = spec ):
@@ -1605,24 +1626,6 @@ def test_invalid_formats(self):
16051626
16061627 invalid_specs = [
16071628 'Q6f' , # regression test
1608- # illegal to use fill or alignment when zero padding
1609- 'X>010f' ,
1610- 'X<010f' ,
1611- 'X^010f' ,
1612- 'X=010f' ,
1613- '0>010f' ,
1614- '0<010f' ,
1615- '0^010f' ,
1616- '0=010f' ,
1617- '>010f' ,
1618- '<010f' ,
1619- '^010f' ,
1620- '=010e' ,
1621- '=010f' ,
1622- '=010g' ,
1623- '=010%' ,
1624- '>00.2f' ,
1625- '>00f' ,
16261629 # Missing precision
16271630 '.e' ,
16281631 '.f' ,
0 commit comments