MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / test_project_euler

Function test_project_euler

scripts/validate_solutions.py:98–108  ·  view source on GitHub ↗

Testing for all Project Euler solutions

(solution_path: pathlib.Path)

Source from the content-addressed store, hash-verified

96 ids=lambda path: f"{path.parent.name}/{path.name}",
97)
98def test_project_euler(solution_path: pathlib.Path) -> None:
99 """Testing for all Project Euler solutions"""
100 # problem_[extract this part] and pad it with zeroes for width 3
101 problem_number: str = solution_path.parent.name[8:].zfill(3)
102 expected: str = PROBLEM_ANSWERS[problem_number]
103 solution_module = convert_path_to_module(solution_path)
104 answer = str(solution_module.solution())
105 answer = hashlib.sha256(answer.encode()).hexdigest()
106 assert answer == expected, (
107 f"Expected solution to {problem_number} to have hash {expected}, got {answer}"
108 )

Callers

nothing calls this directly

Calls 2

convert_path_to_moduleFunction · 0.85
encodeMethod · 0.45

Tested by

no test coverage detected