Visitar URL original
bpo-29613: Added support for SameSite cookies by akash0x53 · Pull Request #214 · python/cpython · GitHub
Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Clubbed test cases for same attribute into single.
  • Loading branch information
akash0x53 committed Feb 28, 2017
commit a6cbc20f3df0b09665ac213ce11b49026f06ebdc
19 changes: 8 additions & 11 deletions Lib/test/test_http_cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,14 @@ def test_set_secure_httponly_attrs(self):
self.assertEqual(C.output(),
'Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Secure')

def test_samesite_strict_attrs(self):
C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
C['Customer']['samesite'] = "Strict"
self.assertEqual(C.output(),
'Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=Strict')

def test_samesite_lax_attrs(self):
C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
C['Customer']['samesite'] = "Lax"
self.assertEqual(C.output(),
'Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=Lax')
def test_samesite_attrs(self):
samesite_values = ("Strict", "Lax")
for val in samesite_values:
with self.subTest(val=val):
C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
C['Customer']['samesite'] = val
self.assertEqual(C.output(),
'Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%s' % val)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation missing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative. It just an illusion i guess. Perfectly showing in my vim.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Tim meant was that the second argument needs to be indented, like:

self.assertEqual(C.output(),
                 'Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%s' % val)

or even better:

expected = f'Set-Cookie: Customer="WILE_E_COYOTE"; SameSite={val}'
self.assertEqual(C.output(), expected)


def test_secure_httponly_false_if_not_present(self):
C = cookies.SimpleCookie()
Expand Down