Fix PyPy tests
MODIFY
.travis.yml
.travis.yml
@@ -102,10 +102,6 @@ matrix:
script:
- ./_travis/deploy.sh
- allow_failures:
- - python: pypy3.5-6.0
- - python: pypy2.7-6.0
-
stages:
- name: test
if: tag IS blank

MODIFY
test/test_response.py
test/test_response.py
# -*- coding: utf-8 -*-
+import re
import socket
import zlib
@@ -413,7 +414,7 @@ class TestResponse(object):
# method which is provided by `BufferedReader` wrapper
resp = BufferedReader(resp)
list(TextIOWrapper(resp))
- assert str(ctx.value) == "I/O operation on closed file."
+ assert re.match("I/O operation on closed file.?", str(ctx.value))
def test_io_not_autoclose_textiowrapper(self):
fp = BytesIO(
@@ -437,7 +438,7 @@ class TestResponse(object):
assert resp.closed
with pytest.raises(ValueError) as ctx:
next(reader)
- assert str(ctx.value) == "I/O operation on closed file."
+ assert re.match("I/O operation on closed file.?", str(ctx.value))
def test_streaming(self):
fp = BytesIO(b"foo")

MODIFY
test/test_ssl.py
test/test_ssl.py
+import platform
+import sys
+
import mock
import pytest
from urllib3.util import ssl_
@@ -125,6 +128,9 @@ def test_wrap_socket_given_context_no_load_default_certs():
def test_wrap_socket_given_ca_certs_no_load_default_certs(monkeypatch):
+ if platform.python_implementation() == "PyPy" and sys.version_info[0] == 2:
+ # https://github.com/testing-cabal/mock/issues/438
+ pytest.xfail("fails with PyPy for Python 2 dues to funcsigs bug")
context = mock.create_autospec(ssl_.SSLContext)
context.load_default_certs = mock.Mock()
context.options = 0

MODIFY
test/with_dummyserver/test_socketlevel.py
test/with_dummyserver/test_socketlevel.py
# TODO: Break this module up into pieces. Maybe group by functionality tested
# rather than the socket level-ness of it.
+import platform
+import sys
from urllib3 import HTTPConnectionPool, HTTPSConnectionPool
from urllib3.poolmanager import proxy_from_url
@@ -1350,6 +1352,10 @@ class TestSSL(SocketDummyServerTestCase):
context.load_default_certs.assert_called_with()
def test_ssl_dont_load_default_certs_when_given(self):
+ if platform.python_implementation() == "PyPy" and sys.version_info[0] == 2:
+ # https://github.com/testing-cabal/mock/issues/438
+ pytest.xfail("fails with PyPy for Python 2 dues to funcsigs bug")
+
def socket_handler(listener):
sock = listener.accept()[0]
ssl_sock = ssl.wrap_socket(

Fix PyPy tests (#1694)