Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standard-tests: add override check #24407

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
x
  • Loading branch information
efriis committed Jul 18, 2024
commit f604e464664dba278572a1ee6f6b4a67e0096043
9 changes: 3 additions & 6 deletions libs/partners/groq/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

from typing import Type

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_core.runnables import RunnableBinding

Check failure on line 7 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.12

Ruff (F401)

tests/unit_tests/test_standard.py:7:38: F401 `langchain_core.runnables.RunnableBinding` imported but unused

Check failure on line 7 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.8

Ruff (F401)

tests/unit_tests/test_standard.py:7:38: F401 `langchain_core.runnables.RunnableBinding` imported but unused
from langchain_standard_tests.unit_tests.chat_models import ( # type: ignore[import-not-found]
ChatModelUnitTests,
Person,

Check failure on line 10 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.12

Ruff (F401)

tests/unit_tests/test_standard.py:10:5: F401 `langchain_standard_tests.unit_tests.chat_models.Person` imported but unused

Check failure on line 10 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.8

Ruff (F401)

tests/unit_tests/test_standard.py:10:5: F401 `langchain_standard_tests.unit_tests.chat_models.Person` imported but unused
my_adder_tool,

Check failure on line 11 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.12

Ruff (F401)

tests/unit_tests/test_standard.py:11:5: F401 `langchain_standard_tests.unit_tests.chat_models.my_adder_tool` imported but unused

Check failure on line 11 in libs/partners/groq/tests/unit_tests/test_standard.py

View workflow job for this annotation

GitHub Actions / cd libs/partners/groq / make lint #3.8

Ruff (F401)

tests/unit_tests/test_standard.py:11:5: F401 `langchain_standard_tests.unit_tests.chat_models.my_adder_tool` imported but unused
)

from langchain_groq import ChatGroq
Expand All @@ -18,10 +19,6 @@
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatGroq

@pytest.mark.xfail(reason="Groq does not support tool_choice='any'")
def test_bind_tool_pydantic(self, model: BaseChatModel) -> None:
"""Does not currently support tool_choice='any'."""
if not self.has_tool_calling:
return

tool_model = model.bind_tools([Person, Person.schema(), my_adder_tool])
assert isinstance(tool_model, RunnableBinding)
super().test_bind_tool_pydantic(model)
22 changes: 20 additions & 2 deletions libs/standard-tests/langchain_standard_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,27 @@ def explore_bases(cls: Type) -> None:
deleted_tests = base_tests - running_tests
assert not deleted_tests, f"Standard tests deleted: {deleted_tests}"

overriden_tests = [
overridden_tests = [
method
for method in running_tests
if getattr(self.__class__, method) is not getattr(comparison_class, method)
]
assert not overriden_tests, f"Standard tests overridden: {overriden_tests}"

def is_xfail(method: str) -> bool:
m = getattr(self.__class__, method)
if not hasattr(m, "pytestmark"):
return False
marks = m.pytestmark
return any(
mark.name == "xfail" and mark.kwargs.get("reason") for mark in marks
)

overridden_not_xfail = [
method for method in overridden_tests if not is_xfail(method)
]
assert not overridden_not_xfail, (
"Standard tests overridden without "
f'@pytest.mark.xfail(reason="..."): {overridden_not_xfail}\n'
"Note: reason is required to explain why the standard test has an expected "
"failure."
)
Loading