Bug 1472773 [wpt PR 11757] - Fix some tests in test_request.py for python 3., a=testonly
authorMs2ger <Ms2ger@gmail.com>
Fri, 28 Sep 2018 09:54:02 +0000
changeset 494483 2c74b71ebcf3625340c0563a007bacc595c98750
parent 494482 d32687beccaefe1ce8edb48d3156c0d2775915d0
child 494484 54c47d6ca05acb6f5497aff26fa8d01153584169
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1472773, 11757
milestone64.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 1472773 [wpt PR 11757] - Fix some tests in test_request.py for python 3., a=testonly Automatic update from web-platform-testsFix some tests in test_request.py for python 3. (#11757) -- wpt-commits: 61e09bec3d21b4e9137dadafc20c04cb9be7ce3e wpt-pr: 11757
testing/web-platform/tests/tools/wptserve/tests/functional/test_request.py
--- a/testing/web-platform/tests/tools/wptserve/tests/functional/test_request.py
+++ b/testing/web-platform/tests/tools/wptserve/tests/functional/test_request.py
@@ -1,71 +1,67 @@
-import sys
-
 import pytest
 
 wptserve = pytest.importorskip("wptserve")
 from .base import TestUsingServer
 from wptserve.request import InputFile
 
 
 class TestInputFile(TestUsingServer):
-    @pytest.mark.xfail(sys.version_info >= (3,), reason="wptserve only works on Py2")
     def test_seek(self):
         @wptserve.handlers.handler
         def handler(request, response):
             rv = []
             f = request.raw_input
             f.seek(5)
             rv.append(f.read(2))
-            rv.append(f.tell())
+            rv.append(b"%d" % f.tell())
             f.seek(0)
             rv.append(f.readline())
-            rv.append(f.tell())
+            rv.append(b"%d" % f.tell())
             rv.append(f.read(-1))
-            rv.append(f.tell())
+            rv.append(b"%d" % f.tell())
             f.seek(0)
             rv.append(f.read())
             f.seek(0)
             rv.extend(f.readlines())
 
-            return " ".join(str(item) for item in rv)
+            return b" ".join(rv)
 
         route = ("POST", "/test/test_seek", handler)
         self.server.router.register(*route)
-        resp = self.request(route[1], method="POST", body="12345ab\ncdef")
+        resp = self.request(route[1], method="POST", body=b"12345ab\ncdef")
         self.assertEqual(200, resp.getcode())
-        self.assertEqual(["ab", "7", "12345ab\n", "8", "cdef", "12",
-                          "12345ab\ncdef", "12345ab\n", "cdef"],
-                         resp.read().split(" "))
+        self.assertEqual([b"ab", b"7", b"12345ab\n", b"8", b"cdef", b"12",
+                          b"12345ab\ncdef", b"12345ab\n", b"cdef"],
+                         resp.read().split(b" "))
 
-    @pytest.mark.xfail(sys.version_info >= (3,), reason="wptserve only works on Py2")
     def test_seek_input_longer_than_buffer(self):
         @wptserve.handlers.handler
         def handler(request, response):
             rv = []
             f = request.raw_input
             f.seek(5)
             rv.append(f.read(2))
-            rv.append(f.tell())
+            rv.append(b"%d" % f.tell())
             f.seek(0)
-            rv.append(f.tell())
-            rv.append(f.tell())
-            return " ".join(str(item) for item in rv)
+            rv.append(b"%d" % f.tell())
+            rv.append(b"%d" % f.tell())
+            return b" ".join(rv)
 
         route = ("POST", "/test/test_seek", handler)
         self.server.router.register(*route)
 
         old_max_buf = InputFile.max_buffer_size
         InputFile.max_buffer_size = 10
         try:
-            resp = self.request(route[1], method="POST", body="1"*20)
+            resp = self.request(route[1], method="POST", body=b"1"*20)
             self.assertEqual(200, resp.getcode())
-            self.assertEqual(["11", "7", "0", "0"],
-                            resp.read().split(" "))
+            self.assertEqual([b"11", b"7", b"0", b"0"],
+                             resp.read().split(b" "))
         finally:
             InputFile.max_buffer_size = old_max_buf
 
     def test_iter(self):
         @wptserve.handlers.handler
         def handler(request, response):
             f = request.raw_input
             return b" ".join(line for line in f)