Bug 1472664 [wpt PR 11752] - Fix up test_stash for python 3., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Wed, 25 Jul 2018 17:44:52 +0000
changeset 429032 777a039e7866cfc89d0e47175e3b1e53c090fb81
parent 429031 88d76bcef14098ef115f6b9a40661709854503da
child 429033 a2895ca90d2e8747c2f5f9aa74f815b3801601c3
push id34352
push userapavel@mozilla.com
push dateMon, 30 Jul 2018 09:52:49 +0000
treeherdermozilla-central@dead9fcddd4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1472664, 11752
milestone63.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 1472664 [wpt PR 11752] - Fix up test_stash for python 3., a=testonly Automatic update from web-platform-testsFix up test_stash for python 3. -- wpt-commits: ac40724f7deb9a9dee9a28f093ec6f97032bc126 wpt-pr: 11752
testing/web-platform/tests/tools/wptserve/tests/functional/base.py
testing/web-platform/tests/tools/wptserve/tests/functional/test_stash.py
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/base.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/base.py
@@ -4,17 +4,17 @@ import base64
 import logging
 import os
 import pytest
 import unittest
 
 from six.moves.urllib.parse import urlencode, urlunsplit
 from six.moves.urllib.request import Request as BaseRequest
 from six.moves.urllib.request import urlopen
-from six import iteritems
+from six import binary_type, iteritems
 
 wptserve = pytest.importorskip("wptserve")
 
 logging.basicConfig()
 
 wptserve.logger.set_logger(logging.getLogger())
 
 here = os.path.split(__file__)[0]
@@ -26,20 +26,26 @@ class Request(BaseRequest):
         BaseRequest.__init__(self, *args, **kwargs)
         self.method = "GET"
 
     def get_method(self):
         return self.method
 
     def add_data(self, data):
         if hasattr(data, "items"):
-            data = urlencode(data)
-        print(data)
+            data = urlencode(data).encode("ascii")
+
+        assert isinstance(data, binary_type)
+
+        if hasattr(BaseRequest, "add_data"):
+            BaseRequest.add_data(self, data)
+        else:
+            self.data = data
+
         self.add_header("Content-Length", str(len(data)))
-        BaseRequest.add_data(self, data)
 
 
 class TestUsingServer(unittest.TestCase):
     def setUp(self):
         self.server = wptserve.server.WebTestHttpd(host="localhost",
                                                    port=0,
                                                    use_ssl=False,
                                                    certificate=None,
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/test_stash.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/test_stash.py
@@ -1,26 +1,24 @@
-import sys
 import unittest
 import uuid
 
 import pytest
 
 wptserve = pytest.importorskip("wptserve")
 from wptserve.router import any_method
 from wptserve.stash import StashServer
 from .base import TestUsingServer
 
 
 class TestResponseSetCookie(TestUsingServer):
     def run(self, result=None):
         with StashServer(None, authkey=str(uuid.uuid4())):
             super(TestResponseSetCookie, self).run(result)
 
-    @pytest.mark.xfail(sys.version_info >= (3,), reason="wptserve only works on Py2")
     def test_put_take(self):
         @wptserve.handlers.handler
         def handler(request, response):
             if request.method == "POST":
                 request.server.stash.put(request.POST.first("id"), request.POST.first("data"))
                 data = "OK"
             elif request.method == "GET":
                 data = request.server.stash.take(request.GET.first("id"))
@@ -28,19 +26,19 @@ class TestResponseSetCookie(TestUsingSer
                     return "NOT FOUND"
             return data
 
         id = str(uuid.uuid4())
         route = (any_method, "/test/put_take", handler)
         self.server.router.register(*route)
 
         resp = self.request(route[1], method="POST", body={"id": id, "data": "Sample data"})
-        self.assertEqual(resp.read(), "OK")
+        self.assertEqual(resp.read(), b"OK")
 
         resp = self.request(route[1], query="id=" + id)
-        self.assertEqual(resp.read(), "Sample data")
+        self.assertEqual(resp.read(), b"Sample data")
 
         resp = self.request(route[1], query="id=" + id)
-        self.assertEqual(resp.read(), "NOT FOUND")
+        self.assertEqual(resp.read(), b"NOT FOUND")
 
 
 if __name__ == '__main__':
     unittest.main()