Commit 50f03644 authored by Jason Madden's avatar Jason Madden

Fix a potentially flaky test in test__local.py

Fixes #1167 and fixes #1168
parent d045dd23
......@@ -120,6 +120,7 @@ BaseTestCase = unittest.TestCase
from .flaky import reraiseFlakyTestTimeout
from .flaky import reraiseFlakyTestRaceCondition
from .flaky import reraises_flaky_timeout
from .flaky import reraises_flaky_race_condition
try:
from unittest import mock
......
......@@ -215,7 +215,7 @@ if PYPY:
# This test, which normally takes 4-5s, sometimes
# hangs forever after running two tests. I cannot reproduce,
# it seems highly load dependent. Observed with both libev and libuv.
'test_threading_2.py',
'test__threading_2.py',
]
if PY3 and TRAVIS:
......
......@@ -341,19 +341,26 @@ class TestGeventLocal(greentest.TestCase):
self.assertEqual(count, len(deleted_sentinels))
@greentest.skipOnPyPy("GC makes this non-deterministic, especially on Windows")
@greentest.ignores_leakcheck
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
results = all_local_dicts_for_greenlet(gevent.getcurrent())
self.assertEqual(results,
[((MyLocal, id(x)), {'foo': 42})])
class MyGreenlet(gevent.Greenlet):
results = None
id_x = None
def _run(self): # pylint:disable=method-hidden
x = local()
x.foo = 42
self.id_x = id(x)
self.results = all_local_dicts_for_greenlet(self)
g = MyGreenlet()
g.start()
g.join()
self.assertTrue(g.successful, g)
self.assertEqual(g.results,
[((local, g.id_x), {'foo': 42})])
def test_local_with_abc(self):
# an ABC (or generally any non-exact-type) in the MRO doesn't
......
......@@ -428,6 +428,7 @@ class TestMaxsize(TestCase):
class TestSize(TestCase):
@greentest.reraises_flaky_race_condition()
def test(self):
pool = self.pool = self._makeOne(2, increase=False)
self.assertEqual(pool.size, 0)
......
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