Bug 1497939 [wpt PR 13453] - Python 3: Support checking for multiple headers., a=testonly
☠☠ backed out by 09dd66ffc95a ☠ ☠
authorMs2ger <Ms2ger@gmail.com>
Mon, 15 Oct 2018 16:48:58 +0000
changeset 489893 ecb9978f1b912df708d85e43961a62b26ce28c92
parent 489892 04c3f543129b1aa54b9beae33304c881bb33d5e2
child 489894 ed08ae0756f26271af55ca0fa0c3f293f34e7e2e
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerstestonly
bugs1497939, 13453
milestone64.0a1
Bug 1497939 [wpt PR 13453] - Python 3: Support checking for multiple headers., a=testonly Automatic update from web-platform-testsPython 3: Support checking for multiple headers (#13453) -- wpt-commits: b91e0cd905d8e5db777586e239079c801533440a wpt-pr: 13453
testing/web-platform/tests/tools/wptserve/tests/functional/base.py
testing/web-platform/tests/tools/wptserve/tests/functional/test_pipes.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 binary_type, iteritems
+from six import binary_type, iteritems, PY3
 
 from hyper import HTTP20Connection, tls
 import ssl
 from localpaths import repo_root
 
 wptserve = pytest.importorskip("wptserve")
 
 logging.basicConfig()
@@ -74,16 +74,21 @@ class TestUsingServer(unittest.TestCase)
         if body is not None:
             req.add_data(body)
 
         if auth is not None:
             req.add_header("Authorization", b"Basic %s" % base64.b64encode((b"%s:%s" % auth)))
 
         return urlopen(req)
 
+    def assert_multiple_headers(self, resp, name, values):
+        if PY3:
+            assert resp.info().get_all(name) == values
+        else:
+            assert resp.info()[name] == ", ".join(values)
 
 @pytest.mark.skipif(not wptserve.utils.http2_compatible(), reason="h2 server only works in python 2.7.15")
 class TestUsingH2Server:
     def setup_method(self, test_method):
         self.server = wptserve.server.WebTestHttpd(host="localhost",
                                                    port=0,
                                                    use_ssl=True,
                                                    doc_root=doc_root,
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/test_pipes.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/test_pipes.py
@@ -30,20 +30,19 @@ class TestHeader(TestUsingServer):
         resp = self.request("/document.txt", query="pipe=header(X-Test,PASS)|header(Content-Type,text/html)")
         self.assertEqual(resp.info()["X-TEST"], "PASS")
         self.assertEqual(resp.info()["Content-Type"], "text/html")
 
     def test_multiple_same(self):
         resp = self.request("/document.txt", query="pipe=header(Content-Type,FAIL)|header(Content-Type,text/html)")
         self.assertEqual(resp.info()["Content-Type"], "text/html")
 
-    @pytest.mark.xfail(sys.version_info >= (3,), reason="wptserve only works on Py2")
     def test_multiple_append(self):
         resp = self.request("/document.txt", query="pipe=header(X-Test,1)|header(X-Test,2,True)")
-        self.assertEqual(resp.info()["X-Test"], "1, 2")
+        self.assert_multiple_headers(resp, "X-Test", ["1", "2"])
 
 class TestSlice(TestUsingServer):
     def test_both_bounds(self):
         resp = self.request("/document.txt", query="pipe=slice(1,10)")
         expected = open(os.path.join(doc_root, "document.txt"), 'rb').read()
         self.assertEqual(resp.read(), expected[1:10])
 
     def test_no_upper(self):