Skip to content

Commit 7db7cf4

Browse files
author
Pierre
committed
Update _fn_utils_test.py
1 parent 09ed9b4 commit 7db7cf4

File tree

1 file changed

+33
-29
lines changed

1 file changed

+33
-29
lines changed

workflowai/core/client/_fn_utils_test.py

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import AsyncIterator
1+
from typing import AsyncIterator, Union
22
from unittest.mock import Mock
33

44
import pytest
@@ -116,50 +116,43 @@ async def test_fn_stream_output_only(self, mock_api_client: Mock):
116116
assert chunks[0] == HelloTaskOutput(message="Hello, World!")
117117

118118

119-
def test_clean_docstring():
120-
# Test empty docstring
121-
assert clean_docstring("") == ""
122-
assert clean_docstring(None) == ""
119+
@pytest.mark.parametrize(
120+
("value", "expected"),
121+
[
122+
# Empty docstrings
123+
("", ""),
124+
(None, ""),
123125
124-
# Test single line docstring
125-
assert clean_docstring("Hello world") == "Hello world"
126-
assert clean_docstring(" Hello world ") == "Hello world"
126+
# Single line docstrings
127+
("Hello world", "Hello world"),
128+
(" Hello world ", "Hello world"),
127129
128-
# Test docstring with empty lines at start/end
129-
assert clean_docstring("""
130+
# Docstring with empty lines at start/end
131+
("""
130132
131133
Hello world
132134
133-
""") == "Hello world"
135+
""", "Hello world"),
134136
135-
# Test multi-line docstring with indentation
136-
assert clean_docstring("""
137+
# Multi-line docstring with indentation
138+
("""
137139
First line
138140
Second line
139141
Indented line
140142
Last line
141-
""") == "First line\nSecond line\n Indented line\nLast line"
143+
""", "First line\nSecond line\n Indented line\nLast line"),
142144
143-
# Test docstring with empty lines in between
144-
assert clean_docstring("""
145+
# Docstring with empty lines in between
146+
("""
145147
First line
146148
147149
Second line
148150
149151
Third line
150-
""") == "First line\n\nSecond line\n\nThird line"
152+
""", "First line\n\nSecond line\n\nThird line"),
151153
152-
# Test real-world example
153-
expected = (
154-
"Find the capital city of the country where the input city is located.\n\n"
155-
"Guidelines:\n"
156-
"1. First identify the country where the input city is located\n"
157-
"2. Then provide the capital city of that country\n"
158-
"3. Include an interesting historical or cultural fact about the capital\n"
159-
"4. Be accurate and precise with geographical information\n"
160-
"5. If the input city is itself the capital, still provide the information"
161-
)
162-
assert clean_docstring("""
154+
# Real-world example
155+
("""
163156
Find the capital city of the country where the input city is located.
164157
165158
Guidelines:
@@ -168,4 +161,15 @@ def test_clean_docstring():
168161
3. Include an interesting historical or cultural fact about the capital
169162
4. Be accurate and precise with geographical information
170163
5. If the input city is itself the capital, still provide the information
171-
""") == expected
164+
""",
165+
"Find the capital city of the country where the input city is located.\n\n"
166+
"Guidelines:\n"
167+
"1. First identify the country where the input city is located\n"
168+
"2. Then provide the capital city of that country\n"
169+
"3. Include an interesting historical or cultural fact about the capital\n"
170+
"4. Be accurate and precise with geographical information\n"
171+
"5. If the input city is itself the capital, still provide the information"),
172+
],
173+
)
174+
def test_clean_docstring(value: Union[str, None], expected: str):
175+
assert clean_docstring(value) == expected

0 commit comments

Comments
 (0)