Replace str.rstrip with os.path.splitext
parent
889c2e4f01
commit
bddf5dfcfe
|
@ -11,7 +11,7 @@ if os.path.isfile("a.out"):
|
|||
raise FileExistsError # TODO: generate uuid .out
|
||||
|
||||
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":
|
||||
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":
|
||||
continue
|
||||
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")
|
||||
total_tests, passed_tests = 0, 0
|
||||
for x in to_run:
|
||||
|
|
Loading…
Reference in New Issue