@@ -31,7 +31,7 @@ def get_binary_files():
31
31
32
32
33
33
def get_text_files ():
34
- return (("%s-%s-%s .txt" % ( name , TEXT_ENCODING , NEWLINES ) , size )
34
+ return ((f" { name } - { TEXT_ENCODING } - { NEWLINES } .txt" , size )
35
35
for name , size in get_file_sizes ())
36
36
37
37
@@ -280,18 +280,17 @@ def run_all_tests(options):
280
280
def print_label (filename , func ):
281
281
name = re .split (r'[-.]' , filename )[0 ]
282
282
out .write (
283
- ("[%s] %s... "
284
- % (name .center (7 ), func .__doc__ .strip ())
285
- ).ljust (52 ))
283
+ f"[{ name .center (7 )} ] { func .__doc__ .strip ()} ... " .ljust (52 ))
286
284
out .flush ()
287
285
288
286
def print_results (size , n , real , cpu ):
289
287
bw = n * float (size ) / 1024 ** 2 / real
290
- bw = ( "%4d MiB/s" if bw > 100 else "% .3g MiB/s") % bw
288
+ bw = f" { bw :4d } MiB/s" if bw > 100 else f" { bw : .3g} MiB/s"
291
289
out .write (bw .rjust (12 ) + "\n " )
292
290
if cpu < 0.90 * real :
293
- out .write (" warning: test above used only %d%% CPU, "
294
- "result may be flawed!\n " % (100.0 * cpu / real ))
291
+ out .write (" warning: test above used only "
292
+ f"{ 100.0 * cpu / real } % CPU, "
293
+ "result may be flawed!\n " )
295
294
296
295
def run_one_test (name , size , open_func , test_func , * args ):
297
296
mode = test_func .file_open_mode
@@ -322,15 +321,15 @@ def run_test_family(tests, mode_filter, files, open_func, *make_args):
322
321
"large" : 2 ,
323
322
}
324
323
325
- print ("Python %s" % sys .version )
324
+ print (f "Python { sys .version } " )
326
325
print ("Unicode: PEP 393" )
327
326
print (platform .platform ())
328
327
binary_files = list (get_binary_files ())
329
328
text_files = list (get_text_files ())
330
329
if "b" in options :
331
330
print ("Binary unit = one byte" )
332
331
if "t" in options :
333
- print ("Text unit = one character (%s -decoded)" % TEXT_ENCODING )
332
+ print (f "Text unit = one character ({ TEXT_ENCODING } -decoded)" )
334
333
335
334
# Binary reads
336
335
if "b" in options and "r" in options :
@@ -399,7 +398,7 @@ def prepare_files():
399
398
break
400
399
else :
401
400
raise RuntimeError (
402
- "Couldn't find chunk marker in %s !" % __file__ )
401
+ f "Couldn't find chunk marker in { __file__ } !" )
403
402
if NEWLINES == "all" :
404
403
it = itertools .cycle (["\n " , "\r " , "\r \n " ])
405
404
else :
@@ -445,7 +444,7 @@ def main():
445
444
help = "run write & modify tests" )
446
445
parser .add_option ("-E" , "--encoding" ,
447
446
action = "store" , dest = "encoding" , default = None ,
448
- help = "encoding for text tests (default: %s)" % TEXT_ENCODING )
447
+ help = f "encoding for text tests (default: { TEXT_ENCODING } )" )
449
448
parser .add_option ("-N" , "--newlines" ,
450
449
action = "store" , dest = "newlines" , default = 'lf' ,
451
450
help = "line endings for text tests "
@@ -458,7 +457,7 @@ def main():
458
457
parser .error ("unexpected arguments" )
459
458
NEWLINES = options .newlines .lower ()
460
459
if NEWLINES not in ('lf' , 'cr' , 'crlf' , 'all' ):
461
- parser .error ("invalid 'newlines' option: %r" % NEWLINES )
460
+ parser .error (f "invalid 'newlines' option: { NEWLINES !r } " )
462
461
463
462
test_options = ""
464
463
if options .read :
0 commit comments