:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import pytest
from ee.hogai.utils.yaml import YamlOutputParser
class TestYamlOutputParser:
@pytest.mark.parametrize(
"input_text,expected_output",
[
# Simple YAML dict
("key: value", {"key": "value"}),
# YAML with markdown code block
("```yaml\nkey: value\n```", {"key": "value"}),
# YAML list
("- item1\n- item2", ["item1", "item2"]),
# YAML with markdown and list
("```yaml\n- item1\n- item2\n```", ["item1", "item2"]),
# Nested YAML dict
("parent:\n child: value", {"parent": {"child": "value"}}),
# YAML with markdown and nested structure
("```yaml\nparent:\n child: value\n```", {"parent": {"child": "value"}}),
# YAML with extra whitespace
(" key: value ", {"key": "value"}),
# Empty YAML dict
("{}", {}),
# Empty YAML list
("[]", []),
],
)
def test_parse(self, input_text, expected_output):
parser = YamlOutputParser()
assert parser.parse(input_text) == expected_output