Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
F-park committed Jan 20, 2024
1 parent 2053e13 commit 8676543
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions tests/test_identical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@


def test_identical(solution_file: Path):
level, challenge_name = solution_file.parent.name.split("-", maxsplit=1)
with solution_file.open() as f:
solution_code = f.read()
solution_test = Challenge(
name=challenge_name, level=Level(level), code=solution_code
).test_code

question_file = solution_file.parent / "question.py"
with question_file.open() as f:
question_code = f.read()
question_test = Challenge(
name=challenge_name, level=Level(level), code=question_code
).test_code
def get_test_code(path: Path):
TEST_SPLITTER = "\n## End of test code ##\n"
level, challenge_name = path.parent.name.split("-", maxsplit=1)

with solution_file.open() as f:
challenge_code = f.read()
challenge = Challenge(
name=challenge_name, level=Level(level), code=challenge_code
)

return challenge.test_code.partition(TEST_SPLITTER)[0]

solution_test = get_test_code(solution_file)
question_test = get_test_code(solution_file.parent / "question.py")

assert solution_test.strip() == question_test.strip()

0 comments on commit 8676543

Please sign in to comment.