Exemple #1
0
def test_kill_custom_signal_kill():
    """Start process and shuts it down using signal SIGQUIT passed to kill."""
    executor = Executor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.kill(sig=signal.SIGQUIT)
    assert executor.running() is False
Exemple #2
0
def test_running_process():
    """Start process and shuts it down."""
    executor = Executor('sleep 300')
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False
Exemple #3
0
def test_running_context():
    """Start process and shuts it down."""
    executor = Executor('sleep 300')
    with executor:
        assert executor.running() is True

    assert executor.running() is False
Exemple #4
0
def test_running_context():
    """Start process and shuts it down."""
    executor = Executor(sleep_300)
    with executor:
        assert executor.running() is True

    assert executor.running() is False
Exemple #5
0
def test_kill_custom_signal_kill():
    """Start process and shuts it down using signal SIGQUIT passed to kill."""
    executor = Executor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.kill(sig=signal.SIGQUIT)
    assert executor.running() is False
Exemple #6
0
def test_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT."""
    executor = Executor(sleep_300, sig_stop=signal.SIGQUIT)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False
Exemple #7
0
def test_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT."""
    executor = Executor(sleep_300, sig_stop=signal.SIGQUIT)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False
Exemple #8
0
def test_context_stopped():
    """Start for context, and shuts it for nested context."""
    executor = Executor('sleep 300')
    with executor:
        assert executor.running() is True
        with executor.stopped():
            assert executor.running() is False
        assert executor.running() is True

    assert executor.running() is False
Exemple #9
0
def test_context_stopped():
    """Start for context, and shuts it for nested context."""
    executor = Executor(sleep_300)
    with executor:
        assert executor.running() is True
        with executor.stopped():
            assert executor.running() is False
        assert executor.running() is True

    assert executor.running() is False
Exemple #10
0
def test_running_process(command):
    """Start process and shuts it down."""
    executor = Executor(command)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False

    # check proper __str__ and __repr__ rendering:
    assert 'Executor' in repr(executor)
    assert 'sleep 300' in str(executor)
Exemple #11
0
def test_running_process(command):
    """Start process and shuts it down."""
    executor = Executor(command)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False

    # check proper __str__ and __repr__ rendering:
    assert 'Executor' in repr(executor)
    assert 'sleep 300' in str(executor)
Exemple #12
0
def test_stopping_not_yet_running_executor():
    """
    Test if Executor can be stopped even it was never running.

    We must make sure that it's possible to call .stop() and Executor will not
    raise any exception and .start() can be called afterwards.
    """
    executor = Executor(sleep_300)
    executor.stop()
    executor.start()
    assert executor.running() is True
    executor.stop()
Exemple #13
0
def test_stopping_not_yet_running_executor():
    """
    Test if Executor can be stopped even it was never running.

    We must make sure that it's possible to call .stop() and Executor will not
    raise any exception and .start() can be called afterwards.
    """
    executor = Executor(sleep_300)
    executor.stop()
    executor.start()
    assert executor.running() is True
    executor.stop()