test_globals.py — langchain Source File
Architecture documentation for test_globals.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d15e95c4_3344_c8ce_47d5_14e082f95cb5["test_globals.py"] f3365e3c_fb7a_bb9a_bc79_059b06cb7024["warnings"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> f3365e3c_fb7a_bb9a_bc79_059b06cb7024 7a643532_4569_6aee_810c_1d094e130674["langchain_core.globals"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> 7a643532_4569_6aee_810c_1d094e130674 145ec24a_51ea_76cc_39a8_028da5bb2e8e["langchain_classic.globals"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> 145ec24a_51ea_76cc_39a8_028da5bb2e8e 4075fd38_6e5d_4fc1_617a_55ecfdfd2071["langchain_core"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> 4075fd38_6e5d_4fc1_617a_55ecfdfd2071 e61aa479_9dc0_09a0_8864_cbf23b8b506c["langchain_core.callbacks.manager"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> e61aa479_9dc0_09a0_8864_cbf23b8b506c 9a0fc770_8c3f_14bc_3c7d_37852927778e["langchain_classic.chains.base"] d15e95c4_3344_c8ce_47d5_14e082f95cb5 --> 9a0fc770_8c3f_14bc_3c7d_37852927778e style d15e95c4_3344_c8ce_47d5_14e082f95cb5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import warnings
from langchain_core.globals import get_debug as core_get_debug
from langchain_core.globals import get_verbose as core_get_verbose
from langchain_core.globals import set_debug as core_set_debug
from langchain_core.globals import set_verbose as core_set_verbose
from langchain_classic.globals import get_debug, get_verbose, set_debug, set_verbose
def test_no_warning() -> None:
with warnings.catch_warnings():
warnings.simplefilter("error")
get_debug()
set_debug(False)
get_verbose()
set_verbose(False)
core_get_debug()
core_set_debug(value=False)
core_get_verbose()
core_set_verbose(value=False)
def test_debug_is_settable_via_setter() -> None:
from langchain_core import globals as langchain_globals
from langchain_core.callbacks.manager import _get_debug
previous_value = langchain_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_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)
def test_verbose_is_settable_via_setter() -> None:
from langchain_core import globals as langchain_globals
from langchain_classic.chains.base import _get_verbosity
previous_value = langchain_globals._verbose
previous_fn_reading = _get_verbosity()
assert previous_value == previous_fn_reading
# Flip the value of the flag.
set_verbose(not previous_value)
new_value = langchain_globals._verbose
new_fn_reading = _get_verbosity()
try:
# We successfully changed the value of `verbose`.
assert new_value != previous_value
# If we access `verbose` via a function used elsewhere in langchain,
# it also sees the same new value.
assert new_value == new_fn_reading
# If we access `verbose` via `get_verbose()` we also get the same value.
assert new_value == get_verbose()
finally:
# Make sure we don't alter global state, even if the test fails.
# Always reset `verbose` to the value it had before.
set_verbose(previous_value)
Domain
Subdomains
Dependencies
- langchain_classic.chains.base
- langchain_classic.globals
- langchain_core
- langchain_core.callbacks.manager
- langchain_core.globals
- warnings
Source
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 LangChainCore domain, Runnables subdomain.
What functions are defined in test_globals.py?
test_globals.py defines 3 function(s): test_debug_is_settable_via_setter, test_no_warning, test_verbose_is_settable_via_setter.
What does test_globals.py depend on?
test_globals.py imports 6 module(s): langchain_classic.chains.base, langchain_classic.globals, langchain_core, langchain_core.callbacks.manager, langchain_core.globals, warnings.
Where is test_globals.py in the architecture?
test_globals.py is located at libs/langchain/tests/unit_tests/test_globals.py (domain: LangChainCore, subdomain: Runnables, directory: libs/langchain/tests/unit_tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free