Skip to content

Commit

Permalink
ensure output format on chat enabled model tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Martin <[email protected]>
  • Loading branch information
jmartin-tech committed Dec 19, 2024
1 parent 900fc8f commit 86de116
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/generators/test_huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def test_pipeline_chat(mocker, hf_generator_config):
mock_format = mocker.patch.object(
g, "_format_chat_prompt", wraps=g._format_chat_prompt
)
g.generate("Hello world!")
output = g.generate("Hello world!")
mock_format.assert_called_once()
assert len(output) == 1
for item in output:
assert isinstance(item, str)


def test_inference(mocker, hf_mock_response, hf_generator_config):
Expand Down Expand Up @@ -141,8 +144,11 @@ def test_model_chat(mocker, hf_generator_config):
mock_format = mocker.patch.object(
g, "_format_chat_prompt", wraps=g._format_chat_prompt
)
g.generate("Hello world!")
output = g.generate("Hello world!")
mock_format.assert_called_once()
assert len(output) == 1
for item in output:
assert isinstance(item, str)


def test_select_hf_device():
Expand Down

0 comments on commit 86de116

Please sign in to comment.