Skip to content

Commit 9ef1ec4

Browse files
committed
tests: fix coverage for eval tests (multiprocessing workaround)
1 parent 855a46b commit 9ef1ec4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gptme/eval/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ def run_evals(
181181
"""
182182
Run evals for a list of tests.
183183
"""
184+
# For coverage to work with multiprocessing
185+
# https://pytest-cov.readthedocs.io/en/latest/subprocess-support.html
186+
try:
187+
from pytest_cov.embed import cleanup_on_sigterm # fmt: skip
188+
except ImportError:
189+
pass
190+
else:
191+
cleanup_on_sigterm()
192+
184193
model_results = defaultdict(list)
185194
with ProcessPoolExecutor(parallel) as executor:
186195
model_futures_to_test = {

tests/test_eval.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
@pytest.mark.slow
99
def test_eval_cli():
1010
runner = CliRunner()
11+
test_set = ["hello"]
1112
result = runner.invoke(
1213
main,
1314
[
1415
"--model",
1516
"openai/gpt-4o",
17+
*test_set,
1618
],
1719
)
1820
assert result

0 commit comments

Comments
 (0)