@@ -203,25 +203,18 @@ def test_complex_cookies(self, browser: Browser) -> None:
203203 # but it's ok - https://www.rfc-editor.org/rfc/rfc6265#section-4.1.2.3
204204 assert cookie .domain == '127.0.0.1'
205205
206- def test_malformed_cookie_is_skipped_not_crashing (self , browser : Browser ) -> None :
207- """A cookie the jar rejects is skipped instead of aborting the process.
208-
209- Regression test for https://github.com/apify/impit/issues/478: `set_cookies`
210- runs inside reqwest's cookie-store callback, so a raising `set_cookie` used to
211- `.unwrap()` into a Rust panic that unwound across the FFI boundary and aborted
212- the host process. It must now be caught and the offending cookie skipped, while
213- valid cookies in the same response are still stored.
214- """
206+ def test_rejected_cookie_is_skipped_not_crashing (self , browser : Browser ) -> None :
207+ """A cookie jar rejects are skipped instead of aborting the process."""
215208
216209 class RejectingCookieJar (CookieJar ):
217210 def set_cookie (self , cookie : Cookie ) -> None :
218211 if cookie .name == 'bad' :
219- raise ValueError ('cookie jar rejects this cookie ' )
212+ raise ValueError ('simulate parsing error ' )
220213 super ().set_cookie (cookie )
221214
222215 cookies_jar = RejectingCookieJar ()
223216
224- impit = Client (browser = browser , cookie_jar = cookies_jar , follow_redirects = True )
217+ impit = Client (browser = browser , cookie_jar = RejectingCookieJar () , follow_redirects = True )
225218
226219 url = get_httpbin_url (
227220 '/response-headers' ,
@@ -233,13 +226,10 @@ def set_cookie(self, cookie: Cookie) -> None:
233226 },
234227 )
235228
236- # The request must return normally rather than aborting the interpreter.
237229 response = impit .get (url )
238230 assert response .status_code == 200
239231
240- names = {cookie .name for cookie in cookies_jar }
241- assert 'bad' not in names # the rejected cookie was skipped
242- assert 'good' in names # a valid cookie in the same response is still stored
232+ assert {'good' } == {cookie .name for cookie in cookies_jar }
243233
244234 def test_cookie_jar_works (self , browser : Browser ) -> None :
245235 cookies = Cookies ({'preset-cookie' : '123' })
0 commit comments