Skip to content

Commit

Permalink
Fix error when creating project with more than one project.
Browse files Browse the repository at this point in the history
  • Loading branch information
ste1hi committed Jul 3, 2024
1 parent ad5e0e6 commit 4454d50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion OiRunner/OiRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 7 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 4454d50

Please sign in to comment.