File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,11 @@ def test_generate_content_streaming(self):
112
112
generation_config = generative_models .GenerationConfig (temperature = 0 ),
113
113
)
114
114
for chunk in stream :
115
- assert chunk .text
115
+ assert (
116
+ chunk .text
117
+ or chunk .candidates [0 ].finish_reason
118
+ is generative_models .FinishReason .STOP
119
+ )
116
120
117
121
@pytest .mark .asyncio
118
122
async def test_generate_content_streaming_async (self ):
@@ -123,7 +127,11 @@ async def test_generate_content_streaming_async(self):
123
127
generation_config = generative_models .GenerationConfig (temperature = 0 ),
124
128
)
125
129
async for chunk in async_stream :
126
- assert chunk .text
130
+ assert (
131
+ chunk .text
132
+ or chunk .candidates [0 ].finish_reason
133
+ is generative_models .FinishReason .STOP
134
+ )
127
135
128
136
def test_generate_content_with_parameters (self ):
129
137
model = generative_models .GenerativeModel (
@@ -241,7 +249,11 @@ def test_grounding_google_search_retriever(self):
241
249
tools = [google_search_retriever_tool ],
242
250
generation_config = generative_models .GenerationConfig (temperature = 0 ),
243
251
)
244
- assert response .text
252
+ assert (
253
+ response .candidates [0 ].finish_reason
254
+ is generative_models .FinishReason .RECITATION
255
+ or response .text
256
+ )
245
257
246
258
# Chat
247
259
You can’t perform that action at this time.
0 commit comments