Skip to content

Commit

Permalink
Test _maybe_await
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta committed Aug 24, 2023
1 parent a65f86f commit 05648c6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/tests_asyncio/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
_encode_body,
_get_header_value,
_get_page_content,
_maybe_await,
)


Expand Down Expand Up @@ -142,3 +143,17 @@ async def test_get_header_exception(self):
resource.header_value.side_effect = Exception("nope")
assert await _get_header_value(resource, "asdf") is None
assert await _get_header_value(resource, "qwerty") is None


class TestMaybeAwait(IsolatedAsyncioTestCase):
@pytest.mark.asyncio
async def test_maybe_await(self):
async def _awaitable_identity(x):
return x

assert await _maybe_await(_awaitable_identity("asdf")) == "asdf"
assert await _maybe_await(_awaitable_identity("qwerty")) == "qwerty"
assert await _maybe_await(_awaitable_identity(1234)) == 1234
assert await _maybe_await("foo") == "foo"
assert await _maybe_await("bar") == "bar"
assert await _maybe_await(1234) == 1234

0 comments on commit 05648c6

Please sign in to comment.