Commit 0e515474 authored by Jason Madden's avatar Jason Madden

Another whack-a-mole for Travis; avoid keeping the sockets at all under PyPy

parent d86b1736
...@@ -152,6 +152,10 @@ if PYPY: ...@@ -152,6 +152,10 @@ if PYPY:
## Unknown; can't reproduce locally on OS X ## Unknown; can't reproduce locally on OS X
'FLAKY test_subprocess.py', # timeouts on one test. 'FLAKY test_subprocess.py', # timeouts on one test.
## PyPy3 5.9.0-beta seems to have dropped recvmsg_into?
'test_socket.py',
'FLAKY test_ssl.py',
] ]
......
...@@ -549,7 +549,7 @@ if hasattr(sys, 'pypy_version_info') and sys.version_info[:2] >= (3, 3): ...@@ -549,7 +549,7 @@ if hasattr(sys, 'pypy_version_info') and sys.version_info[:2] >= (3, 3):
if hasattr(sys, 'pypy_version_info') and sys.pypy_version_info[:4] in ( # pylint:disable=no-member if hasattr(sys, 'pypy_version_info') and sys.pypy_version_info[:4] in ( # pylint:disable=no-member
(5, 8, 0, 'beta'), (5, 8, 0, 'beta'), (5, 9, 0, 'beta'),
): ):
# 3.5 is beta. Hard to say what are real bugs in us vs real bugs in pypy. # 3.5 is beta. Hard to say what are real bugs in us vs real bugs in pypy.
# For that reason, we pin these patches exactly to the version in use. # For that reason, we pin these patches exactly to the version in use.
......
...@@ -8,19 +8,20 @@ import unittest ...@@ -8,19 +8,20 @@ import unittest
import errno import errno
import weakref import weakref
from greentest import TestCase import greentest
dirname = os.path.dirname(os.path.abspath(__file__)) dirname = os.path.dirname(os.path.abspath(__file__))
certfile = os.path.join(dirname, '2.7/keycert.pem') certfile = os.path.join(dirname, '2.7/keycert.pem')
pid = os.getpid() pid = os.getpid()
import sys PY3 = greentest.PY3
PY3 = sys.version_info[0] >= 3 PYPY = greentest.PYPY
fd_types = int fd_types = int
if PY3: if PY3:
long = int long = int
fd_types = (int, long) fd_types = (int, long)
WIN = sys.platform.startswith("win") WIN = greentest.WIN
from greentest import get_open_files from greentest import get_open_files
try: try:
...@@ -29,7 +30,7 @@ except ImportError: ...@@ -29,7 +30,7 @@ except ImportError:
psutil = None psutil = None
class Test(TestCase): class Test(greentest.TestCase):
extra_allowed_open_states = () extra_allowed_open_states = ()
...@@ -113,19 +114,28 @@ class Test(TestCase): ...@@ -113,19 +114,28 @@ class Test(TestCase):
self.assert_open(s, s.fileno()) self.assert_open(s, s.fileno())
return s return s
def _close_on_teardown(self, resource): if not PYPY or not greentest.RUNNING_ON_TRAVIS:
# Keeping raw sockets alive keeps SSL sockets
# from being closed too, at least on CPython, so we def _close_on_teardown(self, resource):
# need to use weakrefs # Keeping raw sockets alive keeps SSL sockets
if 'close_on_teardown' not in self.__dict__: # from being closed too, at least on CPython, so we
self.close_on_teardown = [] # need to use weakrefs
self.close_on_teardown.append(weakref.ref(resource)) if 'close_on_teardown' not in self.__dict__:
return resource self.close_on_teardown = []
self.close_on_teardown.append(weakref.ref(resource))
def _tearDownCloseOnTearDown(self): return resource
self.close_on_teardown = [r() for r in self.close_on_teardown if r() is not None]
super(Test, self)._tearDownCloseOnTearDown() def _tearDownCloseOnTearDown(self):
self._tearDownCloseOnTearDown = () self.close_on_teardown = [r() for r in self.close_on_teardown if r() is not None]
super(Test, self)._tearDownCloseOnTearDown()
self._tearDownCloseOnTearDown = ()
else:
# Seeing a weird GC? interaction on linux.
# I can't reproduce locally. Define these as no-ops
# there
def _close_on_teardown(self, resource):
return resource
class TestSocket(Test): class TestSocket(Test):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment