File: test_create.py

package info (click to toggle)
python-txaio 2.5.1%2B2016.10.03.git.623ef68776-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 384 kB
  • ctags: 429
  • sloc: python: 1,968; makefile: 221
file content (27 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (5)
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)