Skip to content

Commit

Permalink
refactor(test_simplebot)🔧: Refactor test_simple_bot_stream_stdout to …
Browse files Browse the repository at this point in the history
…use hypothesis strategies more efficiently

- Replace multiple given decorators with a single one using st.data()
- Use st.tuples to draw system_prompt, human_message, and mock_response together
  • Loading branch information
ericmjl committed Sep 10, 2024
1 parent 621e8e9 commit 8b56779
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/bot/test_simplebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ def test_simple_bot_init(
assert bot.json_mode == json_mode


@given(
system_prompt=st.text(min_size=1),
human_message=st.text(min_size=1),
mock_response=st.text(min_size=1),
)
@given(st.data())
@settings(deadline=None)
def test_simple_bot_stream_stdout(system_prompt, human_message, mock_response):
def test_simple_bot_stream_stdout(data):
"""Test that SimpleBot stream API exists and returns agenerator."""
system_prompt, human_message, mock_response = data.draw(
st.tuples(st.text(min_size=1), st.text(min_size=1), st.text(min_size=1))
)
bot = SimpleBot(system_prompt, stream_target="stdout", mock_response=mock_response)
result = bot(human_message)
assert isinstance(result, AIMessage)
Expand Down

0 comments on commit 8b56779

Please sign in to comment.