Skip to content

Commit 04064e6

Browse files
Add tests for map functions
1 parent f79a9ce commit 04064e6

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

test/test_scheduler.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
_funcq,
4040
_func_no_params,
4141
_func_numpy,
42+
_func_no_return,
4243
)
4344
except:
4445
from utils import (
@@ -51,6 +52,7 @@
5152
_funcq,
5253
_func_no_params,
5354
_func_numpy,
55+
_func_no_return,
5456
)
5557

5658

@@ -183,6 +185,35 @@ def test_map():
183185
assert scheduler.finished
184186

185187

188+
def test_map_no_args():
189+
"""
190+
Tests whether `map()` works correctly with no araguments.
191+
"""
192+
scheduler = Scheduler()
193+
194+
loop = asyncio.get_event_loop()
195+
results: List = loop.run_until_complete(scheduler.map(target=_func_no_params))
196+
197+
expected = _func_no_params()
198+
199+
assert all([r == expected for r in results])
200+
assert scheduler.finished
201+
202+
203+
def test_map_no_return():
204+
"""
205+
Tests whether 'map()' works correctly when the target function
206+
does not return any values.
207+
"""
208+
scheduler = Scheduler()
209+
210+
loop = asyncio.get_event_loop()
211+
results = loop.run_until_complete(scheduler.map(target=_func_no_return))
212+
213+
assert all([r is None for r in results])
214+
assert scheduler.finished
215+
216+
186217
def test_map_blocking():
187218
"""Tests whether `map_blocking()` works correctly."""
188219
scheduler = Scheduler()

test/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_input_output() -> Tuple[List, List]:
4848

4949

5050
def _get_input_output_numpy() -> Tuple[List, List]:
51-
args = [(i, 5000000 + i ** 2) for i in range(15)]
51+
args = [(i, 500000 + i ** 2) for i in range(15)]
5252
expected_output = [(_func_numpy(*a)) for a in args]
5353
return args, expected_output
5454

@@ -77,6 +77,10 @@ def _func_numpy(x, y) -> ndarray:
7777
return numpy.arange(x, y)
7878

7979

80+
def _func_no_return(x: int) -> None:
81+
pass
82+
83+
8084
def _func_no_params() -> float:
8185
return 3.1415
8286

0 commit comments

Comments
 (0)