1
- from typing import AsyncIterator
1
+ from typing import AsyncIterator , Union
2
2
from unittest .mock import Mock
3
3
4
4
import pytest
@@ -116,50 +116,43 @@ async def test_fn_stream_output_only(self, mock_api_client: Mock):
116
116
assert chunks [0 ] == HelloTaskOutput (message = "Hello, World!" )
117
117
118
118
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 , "" ),
123
125
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" ),
127
129
128
- # Test docstring with empty lines at start/end
129
- assert clean_docstring ("""
130
+ # Docstring with empty lines at start/end
131
+ ("""
130
132
131
133
Hello world
132
134
133
- """ ) == "Hello world"
135
+ """ , "Hello world" ),
134
136
135
- # Test multi -line docstring with indentation
136
- assert clean_docstring ("""
137
+ # Multi -line docstring with indentation
138
+ ("""
137
139
First line
138
140
Second line
139
141
Indented line
140
142
Last line
141
- """ ) == "First line\n Second line\n Indented line\n Last line"
143
+ """ , "First line\n Second line\n Indented line\n Last line" ),
142
144
143
- # Test docstring with empty lines in between
144
- assert clean_docstring ("""
145
+ # Docstring with empty lines in between
146
+ ("""
145
147
First line
146
148
147
149
Second line
148
150
149
151
Third line
150
- """ ) == "First line\n \n Second line\n \n Third line"
152
+ """ , "First line\n \n Second line\n \n Third line" ),
151
153
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
+ ("""
163
156
Find the capital city of the country where the input city is located.
164
157
165
158
Guidelines:
@@ -168,4 +161,15 @@ def test_clean_docstring():
168
161
3. Include an interesting historical or cultural fact about the capital
169
162
4. Be accurate and precise with geographical information
170
163
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