Spaces:
Sleeping
Sleeping
File size: 479 Bytes
d6167ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | """Unit tests for programming challenge test-case evaluation logic."""
import pytest
def test_exercise_testcase_scoring():
"""Verify test-case pass rate calculations."""
def calculate_score(passed: int, total: int, max_xp: int = 20) -> int:
if total == 0:
return 0
ratio = passed / total
return int(ratio * max_xp)
assert calculate_score(5, 5) == 20
assert calculate_score(2, 4) == 10
assert calculate_score(0, 5) == 0
|