mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-25 04:49:17 +00:00
core: Add ruff rules PT (pytest) (#29381)
See https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
This commit is contained in:
committed by
GitHub
parent
6896c863e8
commit
8a33402016
@@ -1,5 +1,6 @@
|
||||
import base64
|
||||
import json
|
||||
import re
|
||||
import typing
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, Callable, Optional, Union
|
||||
@@ -513,7 +514,14 @@ def test_trim_messages_bound_model_token_counter() -> None:
|
||||
|
||||
def test_trim_messages_bad_token_counter() -> None:
|
||||
trimmer = trim_messages(max_tokens=10, token_counter={})
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(
|
||||
ValueError,
|
||||
match=re.escape(
|
||||
"'token_counter' expected to be a model that implements "
|
||||
"'get_num_tokens_from_messages()' or a function. "
|
||||
"Received object of type <class 'dict'>."
|
||||
),
|
||||
):
|
||||
trimmer.invoke([HumanMessage("foobar")])
|
||||
|
||||
|
||||
@@ -852,7 +860,9 @@ def test_convert_to_messages_openai_refusal() -> None:
|
||||
assert actual == expected
|
||||
|
||||
# Raises error if content is missing.
|
||||
with pytest.raises(ValueError):
|
||||
with pytest.raises(
|
||||
ValueError, match="Message dict must contain 'role' and 'content' keys"
|
||||
):
|
||||
convert_to_messages([{"role": "assistant", "refusal": "9.1"}])
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user