MCPcopy
hub / github.com/aio-libs/aiohttp / test_response_cookies

Function test_response_cookies

tests/test_web_response.py:439–461  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

437
438
439def test_response_cookies():
440 resp = StreamResponse()
441
442 assert resp.cookies == {}
443 assert str(resp.cookies) == ''
444
445 resp.set_cookie('name', 'value')
446 assert str(resp.cookies) == 'Set-Cookie: name=value; Path=/'
447 resp.set_cookie('name', 'other_value')
448 assert str(resp.cookies) == 'Set-Cookie: name=other_value; Path=/'
449
450 resp.cookies['name'] = 'another_other_value'
451 resp.cookies['name']['max-age'] = 10
452 assert (str(resp.cookies) ==
453 'Set-Cookie: name=another_other_value; Max-Age=10; Path=/')
454
455 resp.del_cookie('name')
456 expected = 'Set-Cookie: name=("")?; Max-Age=0; Path=/'
457 assert re.match(expected, str(resp.cookies))
458
459 resp.set_cookie('name', 'value', domain='local.host')
460 expected = 'Set-Cookie: name=value; Domain=local.host; Path=/'
461 assert str(resp.cookies) == expected
462
463
464def test_response_cookie_path():

Callers

nothing calls this directly

Calls 4

set_cookieMethod · 0.95
del_cookieMethod · 0.95
StreamResponseClass · 0.90
matchMethod · 0.45

Tested by

no test coverage detected