Home / Function/ test_whole_class_inherited_beta() — langchain Function Reference

test_whole_class_inherited_beta() — langchain Function Reference

Architecture documentation for the test_whole_class_inherited_beta() function in test_beta_decorator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  5ce3ba38_d4ac_6af2_7999_a057053a3bea["test_whole_class_inherited_beta()"]
  af0bb3cc_9182_00c9_fc61_39029170b37e["test_beta_decorator.py"]
  5ce3ba38_d4ac_6af2_7999_a057053a3bea -->|defined in| af0bb3cc_9182_00c9_fc61_39029170b37e
  33df2ed1_85c9_dac9_5d92_a75fb085e76c["beta_method()"]
  5ce3ba38_d4ac_6af2_7999_a057053a3bea -->|calls| 33df2ed1_85c9_dac9_5d92_a75fb085e76c
  style 5ce3ba38_d4ac_6af2_7999_a057053a3bea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/_api/test_beta_decorator.py lines 283–351

def test_whole_class_inherited_beta() -> None:
    """Test whole class beta status for inherited class.

    The original version of beta decorator created duplicates with
    '.. beta::'.
    """

    # Test whole class beta status
    @beta()
    class BetaClass:
        @beta()
        def beta_method(self) -> str:
            """Original doc."""
            return "This is a beta method."

    @beta()
    class InheritedBetaClass(BetaClass):
        @beta()
        def beta_method(self) -> str:
            """Original doc."""
            return "This is a beta method 2."

    with warnings.catch_warnings(record=True) as warning_list:
        warnings.simplefilter("always")

        obj = BetaClass()
        assert obj.beta_method() == "This is a beta method."

        assert len(warning_list) == 2
        warning = warning_list[0].message
        assert str(warning) == (
            "The class `test_whole_class_inherited_beta.<locals>.BetaClass` "
            "is in beta. It is actively being worked on, so the "
            "API may change."
        )

        warning = warning_list[1].message
        assert str(warning) == (
            "The method `test_whole_class_inherited_beta.<locals>.BetaClass."
            "beta_method` is in beta. It is actively being worked on, so "
            "the API may change."
        )

    with warnings.catch_warnings(record=True) as warning_list:
        warnings.simplefilter("always")

        obj = InheritedBetaClass()
        assert obj.beta_method() == "This is a beta method 2."

        assert len(warning_list) == 2
        warning = warning_list[0].message
        assert str(warning) == (
            "The class `test_whole_class_inherited_beta.<locals>.InheritedBetaClass` "
            "is in beta. "
            "It is actively being worked on, so the "
            "API may change."
        )

        warning = warning_list[1].message
        assert str(warning) == (
            "The method `test_whole_class_inherited_beta.<locals>.InheritedBetaClass."
            "beta_method` is in beta. "
            "It is actively being worked on, so "
            "the API may change."
        )

        # if .. beta:: was inserted only once:
        if obj.__doc__ is not None:
            assert obj.__doc__.count(".. beta::") == 1

Subdomains

Frequently Asked Questions

What does test_whole_class_inherited_beta() do?
test_whole_class_inherited_beta() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/_api/test_beta_decorator.py.
Where is test_whole_class_inherited_beta() defined?
test_whole_class_inherited_beta() is defined in libs/core/tests/unit_tests/_api/test_beta_decorator.py at line 283.
What does test_whole_class_inherited_beta() call?
test_whole_class_inherited_beta() calls 1 function(s): beta_method.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free