Home / File/ test_globals.py — langchain Source File

test_globals.py — langchain Source File

Architecture documentation for test_globals.py, a python file in the langchain codebase. 3 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  369a7f7f_397d_dfc9_0b8c_0b3de4f46f0e["test_globals.py"]
  3fb4a817_a89e_f069_6543_9c06e36d4338["langchain_core"]
  369a7f7f_397d_dfc9_0b8c_0b3de4f46f0e --> 3fb4a817_a89e_f069_6543_9c06e36d4338
  e8ec017e_6c91_4b34_675f_2a96c5aa9be6["langchain_core.callbacks.manager"]
  369a7f7f_397d_dfc9_0b8c_0b3de4f46f0e --> e8ec017e_6c91_4b34_675f_2a96c5aa9be6
  85390fd0_d51c_6478_9be2_2d6a9c15d720["langchain_core.globals"]
  369a7f7f_397d_dfc9_0b8c_0b3de4f46f0e --> 85390fd0_d51c_6478_9be2_2d6a9c15d720
  style 369a7f7f_397d_dfc9_0b8c_0b3de4f46f0e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import langchain_core
from langchain_core.callbacks.manager import _get_debug
from langchain_core.globals import get_debug, set_debug


def test_debug_is_settable_via_setter() -> None:
    previous_value = langchain_core.globals._debug
    previous_fn_reading = _get_debug()
    assert previous_value == previous_fn_reading

    # Flip the value of the flag.
    set_debug(not previous_value)

    new_value = langchain_core.globals._debug
    new_fn_reading = _get_debug()

    try:
        # We successfully changed the value of `debug`.
        assert new_value != previous_value

        # If we access `debug` via a function used elsewhere in langchain,
        # it also sees the same new value.
        assert new_value == new_fn_reading

        # If we access `debug` via `get_debug()` we also get the same value.
        assert new_value == get_debug()
    finally:
        # Make sure we don't alter global state, even if the test fails.
        # Always reset `debug` to the value it had before.
        set_debug(previous_value)

Subdomains

Dependencies

  • langchain_core
  • langchain_core.callbacks.manager
  • langchain_core.globals

Frequently Asked Questions

What does test_globals.py do?
test_globals.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_globals.py?
test_globals.py defines 1 function(s): test_debug_is_settable_via_setter.
What does test_globals.py depend on?
test_globals.py imports 3 module(s): langchain_core, langchain_core.callbacks.manager, langchain_core.globals.
Where is test_globals.py in the architecture?
test_globals.py is located at libs/core/tests/unit_tests/test_globals.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests).

Analyze Your Own Codebase

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

Try Supermodel Free