|
27 | 27 |
|
28 | 28 | from scheduler.Scheduler import Scheduler |
29 | 29 | from scheduler.Task import Task |
30 | | -from test.utils import _long_task, _get_input_output, assert_results, _func, _funcq |
| 30 | +from test.utils import ( |
| 31 | + _long_task, |
| 32 | + _get_input_output, |
| 33 | + assert_results, |
| 34 | + _func, |
| 35 | + _funcq, |
| 36 | + _func_no_params, |
| 37 | +) |
31 | 38 |
|
32 | 39 |
|
33 | 40 | def test_add_process(): |
@@ -61,6 +68,23 @@ def test_add(): |
61 | 68 | assert scheduler.finished |
62 | 69 |
|
63 | 70 |
|
| 71 | +def test_run_no_params(): |
| 72 | + """Tests whether `run()` works correctly on a function with no parameters.""" |
| 73 | + scheduler = Scheduler() |
| 74 | + |
| 75 | + expected = _func_no_params() |
| 76 | + for a in range(50): |
| 77 | + scheduler.add(target=_func_no_params) |
| 78 | + |
| 79 | + loop = asyncio.get_event_loop() |
| 80 | + results: List = loop.run_until_complete(scheduler.run()) |
| 81 | + |
| 82 | + for r in results: |
| 83 | + assert r == expected |
| 84 | + |
| 85 | + assert scheduler.finished |
| 86 | + |
| 87 | + |
64 | 88 | def test_multiprocess(): |
65 | 89 | """Tests whether `add()` works correctly with `multiprocess` instead of `multiprocessing`.""" |
66 | 90 | scheduler = Scheduler() |
@@ -97,15 +121,16 @@ def test_run_blocking(): |
97 | 121 |
|
98 | 122 |
|
99 | 123 | def test_run_async(): |
| 124 | + """Tests whether `run()` works correctly.""" |
100 | 125 | scheduler = Scheduler() |
101 | 126 |
|
102 | 127 | args, expected = _get_input_output() |
103 | 128 | for a in args: |
104 | 129 | scheduler.add(target=_func, args=a) |
105 | 130 |
|
106 | 131 | loop = asyncio.get_event_loop() |
107 | | - |
108 | 132 | results: List[Tuple[int, int, int]] = loop.run_until_complete(scheduler.run()) |
| 133 | + |
109 | 134 | assert_results(expected, results) |
110 | 135 |
|
111 | 136 | assert scheduler.finished |
|
0 commit comments