-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
777e4ad
commit b4317f0
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from gapper import post_test, problem, test_cases | ||
from gapper.core.result_synthesizer import ResultSynthesizer | ||
from gapper.core.test_result import TestResult | ||
|
||
|
||
def check_at_least_half_is_correct( | ||
synthesizer: ResultSynthesizer, result_proxy: TestResult | ||
) -> None: | ||
if ( | ||
sum(result.is_passed for result in synthesizer.results) | ||
> len(synthesizer.results) // 2 | ||
): | ||
result_proxy.set_max_score(0) | ||
result_proxy.set_pass_status("passed") | ||
|
||
result_proxy.set_extra_points(5) | ||
|
||
|
||
@test_cases.singular_param_iter([i for i in range(10)], gap_max_score=1) | ||
@post_test(check_at_least_half_is_correct) | ||
@problem() | ||
def square(x: int | float) -> int | float: | ||
return x**2 | ||
|
||
|
||
__problem_config__ = { | ||
"is_script": False, | ||
"check_stdout": False, | ||
"mock_input": False, | ||
"captured_context": (), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def square(x: int | float) -> int | float: | ||
return x**2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
|
||
from gapper.core.problem import Problem | ||
from gapper.core.result_synthesizer import ResultSynthesizer | ||
from gapper.core.test_result import TestResult | ||
from tests.conftest import _make_problem_name | ||
|
||
|
||
def test_post_test(request: pytest.FixtureRequest) -> None: | ||
problem: Problem = request.getfixturevalue( | ||
_make_problem_name("assess_post_tests.py") | ||
) | ||
results = [ | ||
TestResult("test result", pass_status="passed", max_score=1, score=1) | ||
for _ in range(10) | ||
] | ||
old_len = len(results) | ||
old_score = sum(result.score for result in results) | ||
syn = ResultSynthesizer( | ||
results=results, post_tests=problem.post_tests, total_score=10 | ||
).run_post_tests() | ||
|
||
assert len(results) == old_len + 1 | ||
assert syn.synthesize_score() == old_score + 5 |