Skip to content

Commit

Permalink
fix(tests): fix test_task_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Feb 13, 2024
1 parent 41c03c0 commit 4aac254
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ async def test_task_mapping():
async def test_task_mapping_map_with_sync_iter():
tasks = TaskMapping(_coro_fn)
async for k, v in tasks.map(range(5)):
# this shouldn't work since there is a mapping in progress
with pytest.raises(exceptions.MappingNotEmptyError):
async for k in tasks.map(range(5)):
...
assert isinstance(k, int)
assert isinstance(v, str)
with pytest.raises(exceptions.MappingNotEmptyError):
async for k in tasks.map(range(5), yields='keys'):
assert isinstance(k, int)
tasks = TaskMapping(_coro_fn)
async for k in tasks.map(range(5), yields='keys'):
assert isinstance(k, int)
Expand All @@ -72,13 +73,14 @@ async def async_iter():
async for k, v in tasks.map(async_iter()):
assert isinstance(k, int)
assert isinstance(v, str)
with pytest.raises(exceptions.MappingNotEmptyError):
async for k in tasks.map(async_iter(), yields='keys'):
assert isinstance(k, int)
# this shouldn't work since there is a mapping in progress
with pytest.raises(exceptions.MappingNotEmptyError):
async for k in tasks.map(async_iter()):
...
tasks = TaskMapping(_coro_fn)
async for k in tasks.map(async_iter(), yields='keys'):
assert isinstance(k, int)

async def _coro_fn(i: int) -> str:
i += 1
return str(i) * i
return str(i) * i

0 comments on commit 4aac254

Please sign in to comment.