Commit b86561ba authored by Jason Madden's avatar Jason Madden

Fix tests on Python 3.4: It doesn't have SSLObject.

parent 4324fad0
......@@ -137,17 +137,23 @@ class _contextawaresock(socket._gevent_sock_class): # Python 2: pylint:disable=s
pass
raise AttributeError(name)
_SSLObject_factory = SSLObject
if hasattr(SSLObject, '_create'):
# 3.7 is making thing difficult and won't let you
# actually construct an object
def _SSLObject_factory(sslobj, owner=None, session=None):
s = SSLObject.__new__(SSLObject)
s._sslobj = sslobj
s._sslobj.owner = owner or s
if session is not None:
s._sslobj.session = session
return s
try:
_SSLObject_factory = SSLObject
except NameError:
# 3.4 and below do not have SSLObject, something
# we magically import through copy_globals
pass
else:
if hasattr(SSLObject, '_create'):
# 3.7 is making thing difficult and won't let you
# actually construct an object
def _SSLObject_factory(sslobj, owner=None, session=None):
s = SSLObject.__new__(SSLObject)
s._sslobj = sslobj
s._sslobj.owner = owner or s
if session is not None:
s._sslobj.session = session
return s
class SSLSocket(socket):
"""
......
......@@ -274,7 +274,10 @@ class TestGeventLocal(greentest.TestCase):
# The sentinels should be gone too
self.assertEqual(len(deleted_sentinels), len(greenlets))
@greentest.skipOnLibuvOnPyPyOnWin("GC makes this non-deterministic, especially on Windows")
def test_locals_collected_when_unreferenced_even_in_running_greenlet(self):
# In fact only on Windows do we see GC being an issue;
# pypy2 5.0 on macos and travis don't have a problem.
# https://github.com/gevent/gevent/issues/981
import gevent
import gc
......@@ -308,17 +311,16 @@ class TestGeventLocal(greentest.TestCase):
self.assertEqual(count, len(deleted_sentinels))
@greentest.skipOnPyPy("GC makes this non-deterministic, especially on Windows")
def test_local_dicts_for_greenlet(self):
# In fact, only on Windows do we see gc being an issue;
# pypy2 5.10 on macOS and Travis don't have a problem.
import gevent
from gevent.local import all_local_dicts_for_greenlet
x = MyLocal()
x.foo = 42
del x.sentinel
if greentest.PYPY:
import gc
gc.collect()
results = all_local_dicts_for_greenlet(gevent.getcurrent())
self.assertEqual(results,
[((MyLocal, id(x)), {'foo': 42})])
......
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