mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
d15f481352
This pull request adds unit tests for various output parsers (BooleanOutputParser, CommaSeparatedListOutputParser, and StructuredOutputParser) to ensure their correct functionality and to increase code reliability and maintainability. The tests cover both valid and invalid input cases. Changes: Added unit tests for BooleanOutputParser. Added unit tests for CommaSeparatedListOutputParser. Added unit tests for StructuredOutputParser. Testing: All new unit tests have been executed, and they pass successfully. The overall test suite has been run, and all tests pass. Notes: These tests cover both successful parsing scenarios and error handling for invalid inputs. If any new output parsers are added in the future, corresponding unit tests should also be created to maintain coverage.
21 lines
473 B
Python
21 lines
473 B
Python
from langchain.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 invalid input
|
|
try:
|
|
parser.parse("INVALID")
|
|
assert False, "Should have raised ValueError"
|
|
except ValueError:
|
|
pass
|