Commit b86561ba authored by Jason Madden's avatar Jason Madden

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

parent 4324fad0
...@@ -137,8 +137,14 @@ class _contextawaresock(socket._gevent_sock_class): # Python 2: pylint:disable=s ...@@ -137,8 +137,14 @@ 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
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 # 3.7 is making thing difficult and won't let you
# actually construct an object # actually construct an object
def _SSLObject_factory(sslobj, owner=None, session=None): def _SSLObject_factory(sslobj, owner=None, session=None):
......
...@@ -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