Skip to content

Commit

Permalink
Add most trivial possible test suite, and pass it
Browse files Browse the repository at this point in the history
  • Loading branch information
njsmith committed Oct 7, 2018
1 parent d984879 commit 4f21d83
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion trimeter/_impl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import partial
import operator
import abc

import trio
import outcome
Expand Down Expand Up @@ -134,7 +135,7 @@ async def _worker(
result = (value, result)
elif config.include_index and config.include_value:
result = (index, value, result)
await send_to.send(result)
await config.send_to.send(result)
for meter_state in config.meter_states:
meter_state.notify_task_finished()

Expand Down
28 changes: 28 additions & 0 deletions trimeter/_tests/test_basics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from functools import partial
import trio
from trimeter import run_on_each, amap, run_all

# Just the most basic smoke test of the three functions
async def test_basics():
ran_on = []

async def afn(value):
ran_on.append(value)
return value + 1

await run_on_each(afn, [1, 2, 3])

assert sorted(ran_on) == [1, 2, 3]

async with amap(afn, [1, 2, 3]) as result_channel:
results = []
async for result in result_channel:
results.append(result)
assert sorted(results) == [2, 3, 4]

results = await run_all([
partial(afn, 10),
partial(afn, 11),
partial(afn, 12),
])
assert results == [11, 12, 13]
15 changes: 0 additions & 15 deletions trimeter/_tests/test_example.py

This file was deleted.

0 comments on commit 4f21d83

Please sign in to comment.