Commit b4a3dc40 authored by Denis Bilenko's avatar Denis Bilenko

update test__api.py

- remove test_wait_write_invalid_callback
parent af0e9eae
...@@ -62,25 +62,36 @@ class Test(greentest.TestCase): ...@@ -62,25 +62,36 @@ class Test(greentest.TestCase):
assert 'Invalid switch' in str(result), repr(str(result)) assert 'Invalid switch' in str(result), repr(str(result))
switcher.kill() switcher.kill()
def test_wait_read_invalid_switch(self): def _test_wait_read_invalid_switch(self, sleep):
sock = socket.socket() sock1, sock2 = socket.socketpair()
p = gevent.spawn(util.wrap_errors(AssertionError, socket.wait_read), sock.fileno()) try:
gevent.sleep(0) lst = []
switcher = gevent.spawn(p.switch, None) gevent.get_hub().loop.run_callback(switch_None, lst)
result = p.get() p = gevent.spawn(util.wrap_errors(AssertionError, socket.wait_read), sock1.fileno())
assert isinstance(result, AssertionError), result lst.append(p)
assert 'Invalid switch' in str(result), repr(str(result)) if sleep is not None:
switcher.kill() gevent.sleep(sleep)
result = p.get()
def test_wait_write_invalid_switch(self): assert isinstance(result, AssertionError), result
sock = socket.socket() assert 'Invalid switch' in str(result), repr(str(result))
p = gevent.spawn(util.wrap_errors(AssertionError, socket.wait_write), sock.fileno()) finally:
gevent.sleep(0) sock1.close()
switcher = gevent.spawn(p.switch, None) sock2.close()
result = p.get()
assert isinstance(result, AssertionError), result def test_invalid_switch_None(self):
assert 'Invalid switch' in str(result), repr(str(result)) self._test_wait_read_invalid_switch(None)
switcher.kill()
def test_invalid_switch_0(self):
self._test_wait_read_invalid_switch(0)
def test_invalid_switch_1(self):
self._test_wait_read_invalid_switch(0.001)
# we don't test wait_write the same way, because socket is always ready to write
def switch_None(g):
g[0].switch(None)
class TestTimers(greentest.TestCase): class TestTimers(greentest.TestCase):
......
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