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