Skip to content

Commit 05648c6

Browse files
committed
Test _maybe_await
1 parent a65f86f commit 05648c6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/tests_asyncio/test_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
_encode_body,
1212
_get_header_value,
1313
_get_page_content,
14+
_maybe_await,
1415
)
1516

1617

@@ -142,3 +143,17 @@ async def test_get_header_exception(self):
142143
resource.header_value.side_effect = Exception("nope")
143144
assert await _get_header_value(resource, "asdf") is None
144145
assert await _get_header_value(resource, "qwerty") is None
146+
147+
148+
class TestMaybeAwait(IsolatedAsyncioTestCase):
149+
@pytest.mark.asyncio
150+
async def test_maybe_await(self):
151+
async def _awaitable_identity(x):
152+
return x
153+
154+
assert await _maybe_await(_awaitable_identity("asdf")) == "asdf"
155+
assert await _maybe_await(_awaitable_identity("qwerty")) == "qwerty"
156+
assert await _maybe_await(_awaitable_identity(1234)) == 1234
157+
assert await _maybe_await("foo") == "foo"
158+
assert await _maybe_await("bar") == "bar"
159+
assert await _maybe_await(1234) == 1234

0 commit comments

Comments
 (0)