test_whole_class_inherited_deprecation() — langchain Function Reference
Architecture documentation for the test_whole_class_inherited_deprecation() function in test_deprecation.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bfa45505_acce_661f_bbcc_2315cc9f3b80["test_whole_class_inherited_deprecation()"] 07400ddb_6f57_2ca9_d2d9_e7c7fd98cfc1["test_deprecation.py"] bfa45505_acce_661f_bbcc_2315cc9f3b80 -->|defined in| 07400ddb_6f57_2ca9_d2d9_e7c7fd98cfc1 b076f2d0_d292_f547_2081_ee248d4e87a9["deprecated_method()"] bfa45505_acce_661f_bbcc_2315cc9f3b80 -->|calls| b076f2d0_d292_f547_2081_ee248d4e87a9 style bfa45505_acce_661f_bbcc_2315cc9f3b80 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/_api/test_deprecation.py lines 298–375
def test_whole_class_inherited_deprecation() -> None:
"""Test whole class deprecation for inherited class.
The original version of deprecation decorator created duplicates with
'[*Deprecated*]'.
"""
# Test whole class deprecation
@deprecated(since="2.0.0", removal="3.0.0")
class DeprecatedClass:
def __init__(self) -> None:
"""Original doc."""
@deprecated(since="2.0.0", removal="3.0.0")
def deprecated_method(self) -> str:
"""Original doc."""
return "This is a deprecated method."
@deprecated(since="2.2.0", removal="3.2.0")
class InheritedDeprecatedClass(DeprecatedClass):
"""Inherited deprecated class."""
def __init__(self) -> None:
"""Original doc."""
@deprecated(since="2.2.0", removal="3.2.0")
def deprecated_method(self) -> str:
"""Original doc."""
return "This is a deprecated method."
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always")
obj = DeprecatedClass()
assert obj.deprecated_method() == "This is a deprecated method."
assert len(warning_list) == 2
warning = warning_list[0].message
assert str(warning) == (
"The class `test_whole_class_inherited_deprecation.<locals>."
"DeprecatedClass` was "
"deprecated in tests 2.0.0 and will be removed in 3.0.0"
)
warning = warning_list[1].message
assert str(warning) == (
"The method `test_whole_class_inherited_deprecation.<locals>."
"DeprecatedClass.deprecated_method` was deprecated in "
"tests 2.0.0 and will be removed in 3.0.0"
)
# if [*Deprecated*] was inserted only once:
if obj.__doc__ is not None:
assert obj.__doc__.count("!!! deprecated") == 1
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always")
obj = InheritedDeprecatedClass()
assert obj.deprecated_method() == "This is a deprecated method."
assert len(warning_list) == 2
warning = warning_list[0].message
assert str(warning) == (
"The class "
"`test_whole_class_inherited_deprecation.<locals>.InheritedDeprecatedClass`"
" was deprecated in tests 2.2.0 and will be removed in 3.2.0"
)
warning = warning_list[1].message
assert str(warning) == (
"The method `test_whole_class_inherited_deprecation.<locals>."
"InheritedDeprecatedClass.deprecated_method` was deprecated in "
"tests 2.2.0 and will be removed in 3.2.0"
)
# if [*Deprecated*] was inserted only once:
if obj.__doc__ is not None:
assert obj.__doc__.count("!!! deprecated") == 1
assert "!!! deprecated" in obj.__doc__
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_whole_class_inherited_deprecation() do?
test_whole_class_inherited_deprecation() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/_api/test_deprecation.py.
Where is test_whole_class_inherited_deprecation() defined?
test_whole_class_inherited_deprecation() is defined in libs/core/tests/unit_tests/_api/test_deprecation.py at line 298.
What does test_whole_class_inherited_deprecation() call?
test_whole_class_inherited_deprecation() calls 1 function(s): deprecated_method.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free