Replace str.rstrip with os.path.splitext

multiline-output
drunkendog 2023-09-13 15:51:58 +01:00
parent 889c2e4f01
commit bddf5dfcfe
1 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@ if os.path.isfile("a.out"):
raise FileExistsError # TODO: generate uuid .out raise FileExistsError # TODO: generate uuid .out
file_list = glob.glob(f"{os.path.dirname(__file__)}/**/*.cases", recursive=True) file_list = glob.glob(f"{os.path.dirname(__file__)}/**/*.cases", recursive=True)
file_only_list = [os.path.basename(x.rstrip(".cases")) for x in file_list] file_only_list = [os.path.basename(os.path.splitext(x)[0]) for x in file_list]
if sys.platform == "win32": if sys.platform == "win32":
os.system("color") # enables ANSI escape characters, bug in Python os.system("color") # enables ANSI escape characters, bug in Python
@ -22,7 +22,7 @@ for file_name in glob.glob("*.c", recursive=False):
if should_continue != "y": if should_continue != "y":
continue continue
subprocess.run(["gcc", "-o", "a.out", "-std=c11", "-Wall", "-g", file_name], check=True) subprocess.run(["gcc", "-o", "a.out", "-std=c11", "-Wall", "-g", file_name], check=True)
with open(next(x for x in file_list if file_name.rstrip(".c") in x)) as f: with open(next(x for x in file_list if os.path.splitext(file_name)[0] in x)) as f:
to_run = f.read().split("\n\n") to_run = f.read().split("\n\n")
total_tests, passed_tests = 0, 0 total_tests, passed_tests = 0, 0
for x in to_run: for x in to_run: