@@ -23,40 +23,40 @@ def test_all_solutions(directory_name, compiler_name, expected_solutions):
2323 try :
2424 dir_util .copy_tree (directory_name + "/data/" , "./data/" ) # Copy the data folder that some solutions need
2525 except dir_util .DistutilsFileError :
26- print (color_string (colors .WARNING , "The data folder was unable to be copied from " + directory_name + "/solutions to ./data!\n Some solutions may not be able to compile!\n " ))
26+ print (color_string (colors .WARNING , f "The data folder was unable to be copied from { directory_name } to ./data!\n Some solutions may not be able to compile!\n " ))
2727
2828 passed_tests = 0
2929
3030 for problem , solution in expected_solutions .items ():
3131 print (color_string (colors .BOLD , "===============" ))
32- print (color_string (colors .OKBLUE , " TEST" ) + " : Problem " + str (problem ))
32+ print (f" { color_string (colors .OKBLUE , ' TEST' ) } : Problem { str (problem )} " )
3333
3434 current_file = directory_name + "/Problem" + problem + ".cpp"
3535
3636 print ("\n File: " + current_file )
3737
38- compile_command = compiler_name + " " + current_file + " -std=c++14 -O2"
38+ compile_command = f" { compiler_name } { current_file } -std=c++14 -O2"
3939
4040 print ("Running: " + compile_command )
4141
4242 if (subprocess .call (compile_command .split (), stdout = subprocess .DEVNULL , stderr = subprocess .STDOUT ) != 0 ): # Compile the current file
43- print ("Result: " + color_string (colors .FAIL , " FAILURE" ) + " : File was unable to be compiled!" )
43+ print (f "Result: { color_string (colors .FAIL , ' FAILURE' ) } : File was unable to be compiled!" )
4444 else :
4545 current_output_string = subprocess .check_output (['./a.out' ]).decode ('utf-8' ) # Run the executable and capture the output
4646 if current_output_string .strip ().isdigit ():
4747 current_output = int (current_output_string )
4848
49- print ("\n Expected output: " + color_string (colors .BRIGHTMAGENTA , str (solution )))
50- print ("Current output: " + color_string (colors .BRIGHTMAGENTA , str (current_output )))
49+ print (f "\n Expected output: { color_string (colors .BRIGHTMAGENTA , str (solution ))} " )
50+ print (f "Current output: { color_string (colors .BRIGHTMAGENTA , str (current_output ))} " )
5151
5252 print ("\n Result: " , end = '' )
5353 if current_output == solution :
5454 print (color_string (colors .OKGREEN , "SUCCESS" ))
5555 passed_tests += 1
5656 else :
57- print (color_string (colors .FAIL , " FAILURE" ) + " : Current output " + str (current_output ) + " does not match expected output " + str (solution ) + " !" )
57+ print (f" { color_string (colors .FAIL , ' FAILURE' ) } : Current output { str (current_output )} does not match expected output { str (solution )} !" )
5858 else :
59- print ("Result: " + color_string (colors .FAIL , " FAILURE" ) + " : Expected integer but found: " )
59+ print (f "Result: { color_string (colors .FAIL , ' FAILURE' ) } : Expected integer but found: " )
6060 print (current_output_string )
6161
6262 print (color_string (colors .BOLD , "===============" ))
@@ -74,10 +74,10 @@ def test_all_solutions(directory_name, compiler_name, expected_solutions):
7474 print (color_string (colors .BOLD , str (passed_tests ) + " out of " + str (num_tests ) + " tests were successful." ))
7575
7676 if passed_tests == num_tests :
77- print ("Result: " + color_string (colors .OKGREEN , " SUCCESS" ) )
77+ print (f "Result: { color_string (colors .OKGREEN , ' SUCCESS' ) } " )
7878 return 0
7979 else :
80- print ("Result: " + color_string (colors .FAIL , " SUCCESS" ) )
80+ print (f "Result: { color_string (colors .FAIL , ' SUCCESS' ) } " )
8181 return 1
8282
8383
@@ -96,9 +96,9 @@ def test_all_solutions(directory_name, compiler_name, expected_solutions):
9696
9797 if len (sys .argv ) != 3 :
9898 print ("Error: Missing operands!" )
99- print ("Usage: " + sys .argv [0 ] + " repository-root compiler-name" )
99+ print (f "Usage: { sys .argv [0 ]} repository-root compiler-name" )
100100 sys .exit (1 )
101101 elif not os .path .exists (sys .argv [1 ]):
102- print ("Error: Path " + sys .argv [1 ] + " does not exist!" )
102+ print (f "Error: Path { sys .argv [1 ]} does not exist!" )
103103 else :
104104 sys .exit (test_all_solutions (sys .argv [1 ] + "/solutions" , sys .argv [2 ], expected_solutions ))
0 commit comments