Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Oct 9, 2024
1 parent efc2c3b commit e3e1101
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions python/tests/unit_tests/evaluation/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test the eval runner."""

import asyncio
import functools
import itertools
import json
import random
Expand Down Expand Up @@ -248,6 +249,36 @@ def score_value(run, example):
assert not fake_request.should_fail


def test_evaluate_raises_for_async():
async def my_func(inputs: dict):
pass

match = "Async functions are not supported by"
with pytest.raises(ValueError, match=match):
evaluate(my_func, data="foo")

async def my_other_func(inputs: dict, other_val: int):
pass

with pytest.raises(ValueError, match=match):
evaluate(functools.partial(my_other_func, other_val=3), data="foo")

try:
from langchain_core.runnables import RunnableLambda
except ImportError:
pytest.skip("langchain-core not installed.")

@RunnableLambda
def foo(inputs: dict):
return "bar"

with pytest.raises(ValueError, match=match):
evaluate(foo.ainvoke, data="foo")

with pytest.raises(ValueError, match=match):
evaluate(functools.partial(foo.ainvoke, inputs={"foo": "bar"}), data="foo")


@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9 or higher")
@pytest.mark.parametrize("blocking", [False, True])
async def test_aevaluate_results(blocking: bool) -> None:
Expand Down

0 comments on commit e3e1101

Please sign in to comment.