mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-15 22:44:36 +00:00
core[patch]: fix xml output parser transform (#19530)
Previous PR passed _parser attribute which apparently is not meant to be used by user code and causes non deterministic failures on CI when testing the transform and a transform methods. Reverting this change temporarily.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"""Test XMLOutputParser"""
|
||||
from typing import AsyncIterator
|
||||
from xml.etree.ElementTree import ParseError
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -100,17 +99,3 @@ async def tests_billion_laughs_attack() -> None:
|
||||
|
||||
with pytest.raises(OutputParserException):
|
||||
await parser.aparse(MALICIOUS_XML)
|
||||
|
||||
with pytest.raises(ParseError):
|
||||
# Right now raises undefined entity error
|
||||
assert list(parser.transform(iter(MALICIOUS_XML))) == [
|
||||
{"foo": [{"bar": [{"baz": None}]}]}
|
||||
]
|
||||
|
||||
async def _as_iter(string: str) -> AsyncIterator[str]:
|
||||
for c in string:
|
||||
yield c
|
||||
|
||||
with pytest.raises(ParseError):
|
||||
chunks = [chunk async for chunk in parser.atransform(_as_iter(MALICIOUS_XML))]
|
||||
assert chunks == [{"foo": [{"bar": [{"baz": None}]}]}]
|
||||
|
Reference in New Issue
Block a user