Skip to content

Commit

Permalink
tests : improve "tokens" type check
Browse files Browse the repository at this point in the history
Co-authored-by: Xuan Son Nguyen <[email protected]>
  • Loading branch information
ggerganov and ngxson committed Dec 18, 2024
1 parent 8bcfc55 commit 5bf29af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/server/tests/unit/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_completion(prompt: str, n_predict: int, re_content: str, n_prompt: int,
assert type(res.body["has_new_line"]) == bool
assert match_regex(re_content, res.body["content"])
if return_tokens:
assert res.body["tokens"] != []
assert len(res.body["tokens"]) > 0
assert all(type(tok) == int for tok in res.body["tokens"])
else:
assert res.body["tokens"] == []

Expand Down Expand Up @@ -61,7 +62,8 @@ def test_completion_stream(prompt: str, n_predict: int, re_content: str, n_promp
assert data["generation_settings"]["seed"] == server.seed
assert match_regex(re_content, content)
else:
assert data["tokens"] != []
assert len(res.body["tokens"]) > 0

Check failure on line 65 in examples/server/tests/unit/test_completion.py

View workflow job for this annotation

GitHub Actions / pyright type-check

Cannot access attribute "body" for class "Iterator[dict[Unknown, Unknown]]"   Attribute "body" is unknown (reportAttributeAccessIssue)
assert all(type(tok) == int for tok in res.body["tokens"])

Check failure on line 66 in examples/server/tests/unit/test_completion.py

View workflow job for this annotation

GitHub Actions / pyright type-check

Cannot access attribute "body" for class "Iterator[dict[Unknown, Unknown]]"   Attribute "body" is unknown (reportAttributeAccessIssue)
content += data["content"]


Expand Down

0 comments on commit 5bf29af

Please sign in to comment.