test_boolean_parser.py — langchain Source File
Architecture documentation for test_boolean_parser.py, a python file in the langchain codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3e25fa29_b1cd_e553_3c43_405d9baec4ed["test_boolean_parser.py"] 67ec3255_645e_8b6e_1eff_1eb3c648ed95["re"] 3e25fa29_b1cd_e553_3c43_405d9baec4ed --> 67ec3255_645e_8b6e_1eff_1eb3c648ed95 120e2591_3e15_b895_72b6_cb26195e40a6["pytest"] 3e25fa29_b1cd_e553_3c43_405d9baec4ed --> 120e2591_3e15_b895_72b6_cb26195e40a6 224ab9fb_0538_7d3c_bef3_5f1c82d3a53a["langchain_classic.output_parsers.boolean"] 3e25fa29_b1cd_e553_3c43_405d9baec4ed --> 224ab9fb_0538_7d3c_bef3_5f1c82d3a53a style 3e25fa29_b1cd_e553_3c43_405d9baec4ed fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import re
import pytest
from langchain_classic.output_parsers.boolean import BooleanOutputParser
def test_boolean_output_parser_parse() -> None:
parser = BooleanOutputParser()
# Test valid input
result = parser.parse("YES")
assert result is True
# Test valid input
result = parser.parse("NO")
assert result is False
# Test valid input
result = parser.parse("yes")
assert result is True
# Test valid input
result = parser.parse("no")
assert result is False
# Test valid input
result = parser.parse("Not relevant (NO)")
assert result is False
# Test valid input
result = parser.parse("NOW this is relevant (YES)")
assert result is True
# Test ambiguous input
with pytest.raises(
ValueError,
match=re.escape("Ambiguous response. Both YES and NO in received: YES NO."),
):
parser.parse("YES NO")
with pytest.raises(
ValueError,
match=re.escape("Ambiguous response. Both YES and NO in received: NO YES."),
):
parser.parse("NO YES")
# Bad input
with pytest.raises(
ValueError,
match=re.escape(
"BooleanOutputParser expected output value to include either YES or NO. "
"Received BOOM."
),
):
parser.parse("BOOM")
def test_boolean_output_parser_output_type() -> None:
"""Test the output type of the boolean output parser is a boolean."""
assert BooleanOutputParser().OutputType is bool
Domain
Subdomains
Dependencies
- langchain_classic.output_parsers.boolean
- pytest
- re
Source
Frequently Asked Questions
What does test_boolean_parser.py do?
test_boolean_parser.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in test_boolean_parser.py?
test_boolean_parser.py defines 2 function(s): test_boolean_output_parser_output_type, test_boolean_output_parser_parse.
What does test_boolean_parser.py depend on?
test_boolean_parser.py imports 3 module(s): langchain_classic.output_parsers.boolean, pytest, re.
Where is test_boolean_parser.py in the architecture?
test_boolean_parser.py is located at libs/langchain/tests/unit_tests/output_parsers/test_boolean_parser.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/langchain/tests/unit_tests/output_parsers).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free