[Webkit-unassigned] [Bug 221720] [LayoutTests] Convert http/tests/storageAccess convert PHP to Python

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 12 09:31:08 PST 2021


https://bugs.webkit.org/show_bug.cgi?id=221720

--- Comment #5 from Chris Gambrell <cgambrell at apple.com> ---
(In reply to Jonathan Bedard from comment #3)
> Comment on attachment 419932 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=419932&action=review
> 
> > LayoutTests/http/tests/storageAccess/resources/echo-incoming-cookies-as-json.py:8
> > +if 'HTTP_COOKIE' in os.environ:
> 
> I would do this instead:
> 
> header_cookies = os.environ.get('HTTP_COOKIE')
> header_cookies = header_cookies.split('; ') if header_cookies else []
> 
> then you can take all of this out of the if statement
> 

Like this change, very concise compared to my block


> > LayoutTests/http/tests/storageAccess/resources/get-cookies.py:31
> > +if not cname1:
> 
> Readability suggestion here: If you made the default for name1 the empty
> string (like it is now), but the defaults of name2 and name3 None, you could
> unify this code into a single loop:
> 
> for name in [
>     query.get('name1', [''])[0],
>     query.get('name2', [None])[0],
>     query.get('name3', [None])[0],
> ]:
>     if name is not None:
>         continue
>     cookie = cookies.get(name)
>     if cookie:
>         print(...)
>     else:
>         print(...)
> 

Implemented this change


> > LayoutTests/http/tests/storageAccess/resources/get-cookies.py:48
> > +print('<p id="output"></p>')
> 
> I think this is a good use-case for a multi-line string (ie, ''' <content>
> '''
> 
> > LayoutTests/http/tests/storageAccess/resources/set-cookie.py:20
> > +print('<script>')
> 
> Another code case for a multi-line string.

I like these stylistic changes quite a bit. It makes the large blocks of content much cleaner

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210212/b5b0e2a4/attachment.htm>


More information about the webkit-unassigned mailing list