Test Failed
Push — master ( 9e4203...5a4935 )
by George
01:43
created

test_runner_with_cancelled_error()   A

Complexity

Conditions 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
from unittest import mock
2
3
from concurrent.futures import CancelledError
4
5
from loafer.runners import LoaferRunner
6
7
8
def test_runner_start():
9
    runner = LoaferRunner(loop=mock.Mock())
10
    runner.start()
11
    assert runner.loop.run_forever.called
12
13
14
def test_runner_start_run_until_complete():
0 ignored issues
show
Coding Style Naming introduced by
The name test_runner_start_run_until_complete does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
15
    runner = LoaferRunner(loop=mock.Mock())
16
    runner.stop = mock.Mock()
17
    runner.start(run_forever=False)
18
    assert runner.loop.run_until_complete.called
19
    assert runner.stop.called
20
21
22
def test_runner_stop():
23
    runner = LoaferRunner(loop=mock.Mock())
24
    runner.stop()
25
    assert runner.loop.stop.called
26
27
28
def test_runner_stop_with_callback():
29
    callback = mock.Mock()
30
    runner = LoaferRunner(loop=mock.Mock(), on_stop_callback=callback)
31
    runner.stop()
32
    assert runner.loop.stop.called
33
    assert callback.called
34
35
36
def test_runner_with_cancelled_error():
0 ignored issues
show
Coding Style Naming introduced by
The name test_runner_with_cancelled_error does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
37
    runner = LoaferRunner(loop=mock.Mock())
38
    runner.loop.run_forever.side_effect = CancelledError
39
    runner.start()
40
    assert runner.loop.run_forever.called
41
    assert runner.loop.close.called
42