Bug 1500491 [wpt PR 13623] - Python 3: Fix test_set_cookie., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Thu, 15 Nov 2018 10:14:48 +0000
changeset 503413 623c8426e847a513088ec0c9908488774b58f7ba
parent 503412 a7f16bb1b02d464927456525c064a442ba934ba3
child 503414 b12ab8efbefe006789483f40036d4b1fe8eab05f
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1500491, 13623
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1500491 [wpt PR 13623] - Python 3: Fix test_set_cookie., a=testonly Automatic update from web-platform-testsPython 3: Fix test_set_cookie. (#13623) -- wpt-commits: 43b98d280dc40e98d6414b266ec3fcc87156d5fe wpt-pr: 13623
testing/web-platform/tests/tools/wptserve/tests/functional/test_cookies.py
testing/web-platform/tests/tools/wptserve/wptserve/request.py
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/test_cookies.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/test_cookies.py
@@ -1,9 +1,8 @@
-import sys
 import unittest
 
 import pytest
 
 wptserve = pytest.importorskip("wptserve")
 from .base import TestUsingServer
 
 
@@ -46,17 +45,16 @@ class TestResponseSetCookie(TestUsingSer
         parts = dict(item.split("=") for
                      item in resp.info()["Set-Cookie"].split("; ") if item)
 
         self.assertEqual(parts["name"], "")
         self.assertEqual(parts["Path"], "/")
         #Should also check that expires is in the past
 
 class TestRequestCookies(TestUsingServer):
-    @pytest.mark.xfail(sys.version_info >= (3,), reason="wptserve only works on Py2")
     def test_set_cookie(self):
         @wptserve.handlers.handler
         def handler(request, response):
             return request.cookies["name"].value
 
         route = ("GET", "/test/set_cookie", handler)
         self.server.router.register(*route)
         resp = self.request(route[1], headers={"Cookie": "name=value"})
--- a/testing/web-platform/tests/tools/wptserve/wptserve/request.py
+++ b/testing/web-platform/tests/tools/wptserve/wptserve/request.py
@@ -1,12 +1,12 @@
 import base64
 import cgi
 from six.moves.http_cookies import BaseCookie
-from six import BytesIO, binary_type, text_type
+from six import BytesIO, binary_type, text_type, iteritems, PY3
 import tempfile
 
 from six.moves.urllib.parse import parse_qsl, urlsplit
 
 from . import stash
 from .utils import HTTPException
 
 missing = object()
@@ -314,19 +314,21 @@ class Request(object):
             self.raw_input.seek(pos)
         return self._POST
 
     @property
     def cookies(self):
         if self._cookies is None:
             parser = BaseCookie()
             cookie_headers = self.headers.get("cookie", b"")
+            if PY3:
+                cookie_headers = cookie_headers.decode("iso-8859-1")
             parser.load(cookie_headers)
             cookies = Cookies()
-            for key, value in parser.iteritems():
+            for key, value in iteritems(parser):
                 cookies[key] = CookieValue(value)
             self._cookies = cookies
         return self._cookies
 
     @property
     def headers(self):
         if self._headers is None:
             self._headers = RequestHeaders(self.raw_headers)