1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
import txaio
def test_illegal_args(framework):
try:
txaio.create_future(result=1, error=RuntimeError("foo"))
assert False
except ValueError:
pass
def test_create_result(framework):
f = txaio.create_future(result='foo')
if txaio.using_twisted:
assert f.called
else:
assert f.done()
def test_create_error(framework):
f = txaio.create_future(error=RuntimeError("test"))
if txaio.using_twisted:
assert f.called
else:
assert f.done()
# cancel the error; we expected it
txaio.add_callbacks(f, None, lambda _: None)
|