Commit b5792409 authored by Denis Bilenko's avatar Denis Bilenko

fix some tests to clean up objects

so that they pass on python-dbg
parent b0cf96a8
......@@ -98,12 +98,7 @@ class TestLink(greentest.TestCase):
class TestUnlink(greentest.TestCase):
switch_expected = False
def setUp(self):
greentest.TestCase.setUp(self)
self.p = gevent.spawn(dummy_test_func)
def _test_func(self, link):
p = self.p
def _test_func(self, p, link):
link(dummy_test_func)
assert len(p._links) == 1, p._links
p.unlink(dummy_test_func)
......@@ -113,15 +108,19 @@ class TestUnlink(greentest.TestCase):
assert len(p._links) == 1, p._links
p.unlink(self.setUp)
assert not p._links, p._links
p.kill()
def test_func_link(self):
self._test_func(self.p.link)
p = gevent.spawn(dummy_test_func)
self._test_func(p, p.link)
def test_func_link_value(self):
self._test_func(self.p.link_value)
p = gevent.spawn(dummy_test_func)
self._test_func(p, p.link_value)
def test_func_link_exception(self):
self._test_func(self.p.link_exception)
p = gevent.spawn(dummy_test_func)
self._test_func(p, p.link_exception)
class LinksTestCase(greentest.TestCase):
......
......@@ -2,31 +2,30 @@ import gevent
import greentest
class Test(greentest.TestCase):
class appender(object):
count = 2
def __init__(self, lst, item):
self.lst = lst
self.item = item
def setUp(self):
self.lst = []
def __call__(self, *args):
self.lst.append(self.item)
def tearDown(self):
self.assertEqual(self.lst, range(self.count))
def test_greenlet_link(self):
# test that links are executed in the same order as they were added
g = gevent.spawn(self.lst.append, 0)
class Test(greentest.TestCase):
class appender(object):
count = 2
def __init__(myself, item):
myself.item = item
def test_greenlet_link(self):
lst = []
def __call__(myself, *args):
self.lst.append(myself.item)
# test that links are executed in the same order as they were added
g = gevent.spawn(lst.append, 0)
for i in xrange(1, self.count):
g.link(appender(i))
g.link(appender(lst, i))
g.join()
self.assertEqual(lst, range(self.count))
class Test3(Test):
......
......@@ -11,4 +11,7 @@ else:
import subprocess
for _ in xrange(5):
out, err = subprocess.Popen([sys.executable, __file__, 'runtestcase'], stderr=subprocess.PIPE).communicate()
assert err.strip() == 'bye', err
if 'refs' in err:
assert err.startswith('bye'), repr(err)
else:
assert err.strip() == 'bye', repr(err)
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