mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 17:08:47 +00:00
Add unit test for overridden lc_namespace (#16093)
This commit is contained in:
parent
52114bdfac
commit
770f57196e
@ -30,10 +30,9 @@
|
||||
"lc": 1,
|
||||
"type": "constructor",
|
||||
"id": [
|
||||
"tests",
|
||||
"unit_tests",
|
||||
"load",
|
||||
"test_dump",
|
||||
"my",
|
||||
"special",
|
||||
"namespace",
|
||||
"SpecialPerson"
|
||||
],
|
||||
"kwargs": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
"""Test for Serializable base class"""
|
||||
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import pytest
|
||||
from langchain_community.chat_models.openai import ChatOpenAI
|
||||
@ -37,6 +37,10 @@ class SpecialPerson(Person):
|
||||
|
||||
another_visible: str = "bye"
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> List[str]:
|
||||
return ["my", "special", "namespace"]
|
||||
|
||||
# Gets merged with parent class's secrets
|
||||
@property
|
||||
def lc_secrets(self) -> Dict[str, str]:
|
||||
@ -58,6 +62,7 @@ def test_person(snapshot: Any) -> None:
|
||||
sp = SpecialPerson(another_secret="Wooo", secret="Hmm")
|
||||
assert dumps(sp, pretty=True) == snapshot
|
||||
assert Person.lc_id() == ["tests", "unit_tests", "load", "test_dump", "Person"]
|
||||
assert SpecialPerson.lc_id() == ["my", "special", "namespace", "SpecialPerson"]
|
||||
|
||||
|
||||
def test_typeerror() -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user