From 4454d5044a708daedabbb119fb1306b8c1b54c08 Mon Sep 17 00:00:00 2001 From: ste1hi <1874076121@qq.com> Date: Wed, 3 Jul 2024 18:44:08 +0800 Subject: [PATCH] Fix error when creating project with more than one project. --- OiRunner/OiRunner.py | 2 +- tests/test_project.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/OiRunner/OiRunner.py b/OiRunner/OiRunner.py index 771b9ff..2a129f1 100644 --- a/OiRunner/OiRunner.py +++ b/OiRunner/OiRunner.py @@ -89,8 +89,8 @@ def make(self, name: str, questions: int, follow_question: bool, if_create_cpp_f open(f"T{question_number}.cpp", "x").close() question_setting[str(question_number)]["cpp"] = f"T{question_number}.cpp" settings["questions"] = question_setting + os.chdir("..") - os.chdir("..") with open(settings_path, "w") as set: json.dump(settings, set) diff --git a/tests/test_project.py b/tests/test_project.py index 7942db8..351818e 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -69,6 +69,13 @@ def test_parse(self, error, help): error.assert_called_with("The subcommand is required.") help.assert_called_once() + # It's a regression test. See details:https://github.com/ste1hi/OiRunner/issues/23 + def test_create_project_more_than_one_question(self): + self.oirunner.make("test", 2, False, False) + self.assertTrue(os.path.exists("T1")) + self.assertTrue(os.path.exists("T2")) + self.assertTrue(os.path.exists(".OiRunner")) + def test_make(self): os.chdir("..") # In test_setting, .OiRunner folder already exist. with self.assertRaises(Exceptions.ProjectAlreadyExists):