mirror of
https://github.com/langchain-ai/kork.git
synced 2026-06-30 22:28:05 -04:00
28 lines
904 B
Python
28 lines
904 B
Python
from kork.utils import unwrap_code, unwrap_tag, wrap_in_tag
|
|
|
|
|
|
def test_unwrap_tag() -> None:
|
|
"""Test unwrap_tag."""
|
|
# Test with an empty string
|
|
assert unwrap_tag("", "") is None
|
|
|
|
# Test with a string that doesn't contain the tag
|
|
assert unwrap_tag("table", "This is some text.") is None
|
|
|
|
# Test with a string that does contain the tag
|
|
assert unwrap_tag("table", "<table>hello</table>") == "hello"
|
|
|
|
# Test with a string that does contain the tag and some stuff before and after
|
|
assert unwrap_tag("table", "prefix<table>hello</table>suffix") == "hello"
|
|
|
|
|
|
def test_wrap_in_tag() -> None:
|
|
"""Test wrap_in_tag."""
|
|
assert wrap_in_tag("table", "hello") == "<table>hello</table>"
|
|
|
|
|
|
def test_unwrap_code() -> None:
|
|
"""Unwrap code."""
|
|
assert unwrap_code("python", "") is None
|
|
assert unwrap_code("python", "```python\nprint('hello')\n```") == "print('hello')"
|