File: test_awaitable.py

package info (click to toggle)
python-promise 2.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 2,681; sh: 13; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 534 bytes parent folder | download | duplicates (2)
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
from pytest import mark
from time import sleep
from promise import Promise


@mark.asyncio
async def test_await():
    await Promise.resolve(True)


@mark.asyncio
async def test_await_time():
    def resolve_or_reject(resolve, reject):
        sleep(.1)
        resolve(True)

    p = Promise(resolve_or_reject)
    assert p.get() is True


@mark.asyncio
async def test_promise_coroutine():
    async def my_coro():
        await Promise.resolve(True)

    promise = Promise.resolve(my_coro())
    assert isinstance(promise, Promise)