From bddf5dfcfe71dc0ff337a103a4c0e1727173523b Mon Sep 17 00:00:00 2001 From: drunkendog Date: Wed, 13 Sep 2023 15:51:58 +0100 Subject: [PATCH] Replace str.rstrip with os.path.splitext --- run-tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run-tests.py b/run-tests.py index f92261c..fb2f1e9 100644 --- a/run-tests.py +++ b/run-tests.py @@ -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: