From d1b52f8d804d7b0ad196d97aa7a7cda13b7fa786 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Mon, 23 Sep 2019 11:16:48 -0700 Subject: [PATCH] try to fix test failing due to url-encoding https://travis-ci.org/internetarchive/warcprox/jobs/588557539 test_domain_data_soft_limit not sure what changed, maybe the requests library, though i can't reproduce locally, but explicitly decoding should fix the problem --- tests/test_warcprox.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_warcprox.py b/tests/test_warcprox.py index 884ddd4..d95f51c 100755 --- a/tests/test_warcprox.py +++ b/tests/test_warcprox.py @@ -52,6 +52,7 @@ import mock import email.message import socketserver from concurrent import futures +import urllib.parse try: import http.server as http_server @@ -175,8 +176,10 @@ class _TestHttpRequestHandler(http_server.BaseHTTPRequestHandler): def build_response(self): m = re.match(r'^/([^/]+)/([^/]+)$', self.path) if m is not None: - special_header = 'warcprox-test-header: {}!'.format(m.group(1)).encode('utf-8') - payload = 'I am the warcprox test payload! {}!\n'.format(10*m.group(2)).encode('utf-8') + seg1 = urllib.parse.unquote(m.group(1)) + seg2 = urllib.parse.unquote(m.group(2)) + special_header = 'warcprox-test-header: {}!'.format(seg1).encode('utf-8') + payload = 'I am the warcprox test payload! {}!\n'.format(10*seg2).encode('utf-8') headers = (b'HTTP/1.1 200 OK\r\n' + b'Content-Type: text/plain\r\n' + special_header + b'\r\n' @@ -1351,7 +1354,7 @@ def test_domain_data_soft_limit( warcprox_.proxy.remote_connection_pool.clear() # novel, pushes stats over the limit - url = 'https://muh.XN--Zz-2Ka.locALHOst:{}/z/~'.format(https_daemon.server_port) + url = 'https://muh.XN--Zz-2Ka.locALHOst:{}/z/%7E'.format(https_daemon.server_port) response = requests.get( url, proxies=archiving_proxies, headers=headers, stream=True, verify=False)