@@ -435,6 +435,17 @@ def test(i, format_spec, result):
435435 self .assertEqual (value .__format__ (format_spec ),
436436 float (value ).__format__ (format_spec ))
437437
438+ # Issue 6902
439+ test (123456 , "0<20" , '12345600000000000000' )
440+ test (123456 , "1<20" , '12345611111111111111' )
441+ test (123456 , "*<20" , '123456**************' )
442+ test (123456 , "0>20" , '00000000000000123456' )
443+ test (123456 , "1>20" , '11111111111111123456' )
444+ test (123456 , "*>20" , '**************123456' )
445+ test (123456 , "0=20" , '00000000000000123456' )
446+ test (123456 , "1=20" , '11111111111111123456' )
447+ test (123456 , "*=20" , '**************123456' )
448+
438449 def test_long__format__ (self ):
439450 def test (i , format_spec , result ):
440451 # make sure we're not accidentally checking ints
@@ -532,6 +543,16 @@ def test(i, format_spec, result):
532543 for value in [0L , 1L , - 1L , 100L , - 100L , 1234567890L , - 1234567890L ]:
533544 self .assertEqual (value .__format__ (format_spec ),
534545 float (value ).__format__ (format_spec ))
546+ # Issue 6902
547+ test (123456L , "0<20" , '12345600000000000000' )
548+ test (123456L , "1<20" , '12345611111111111111' )
549+ test (123456L , "*<20" , '123456**************' )
550+ test (123456L , "0>20" , '00000000000000123456' )
551+ test (123456L , "1>20" , '11111111111111123456' )
552+ test (123456L , "*>20" , '**************123456' )
553+ test (123456L , "0=20" , '00000000000000123456' )
554+ test (123456L , "1=20" , '11111111111111123456' )
555+ test (123456L , "*=20" , '**************123456' )
535556
536557 @run_with_locale ('LC_NUMERIC' , 'en_US.UTF8' )
537558 def test_float__format__locale (self ):
@@ -689,6 +710,17 @@ def test(f, format_spec, result):
689710 self .assertRaises (ValueError , format , 0.0 , '#' )
690711 self .assertRaises (ValueError , format , 0.0 , '#20f' )
691712
713+ # Issue 6902
714+ test (12345.6 , "0<20" , '12345.60000000000000' )
715+ test (12345.6 , "1<20" , '12345.61111111111111' )
716+ test (12345.6 , "*<20" , '12345.6*************' )
717+ test (12345.6 , "0>20" , '000000000000012345.6' )
718+ test (12345.6 , "1>20" , '111111111111112345.6' )
719+ test (12345.6 , "*>20" , '*************12345.6' )
720+ test (12345.6 , "0=20" , '000000000000012345.6' )
721+ test (12345.6 , "1=20" , '111111111111112345.6' )
722+ test (12345.6 , "*=20" , '*************12345.6' )
723+
692724 def test_format_spec_errors (self ):
693725 # int, float, and string all share the same format spec
694726 # mini-language parser.
0 commit comments