Пример #1
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
Пример #2
0
def test_process_output_shell():
    """Start process, check output and shut it down with shell set to True."""
    executor = Executor('echo -n "foobar"', shell=True)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Пример #3
0
def test_process_output(command):
    """Start process, check output and shut it down."""
    executor = Executor(command)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Пример #4
0
def test_process_output():
    """Start process, check output and shut it down."""
    executor = Executor('echo -n "foobar"')
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Пример #5
0
def test_process_output_shell(command):
    """Start process, check output and shut it down with shell set to True."""
    executor = Executor(command, shell=True)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Пример #6
0
def test_stop_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT passed to stop."""
    executor = Executor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.stop(sig=signal.SIGQUIT)
    assert executor.running() is False
Пример #7
0
def test_stop_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT passed to stop."""
    executor = Executor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.stop(sig=signal.SIGQUIT)
    assert executor.running() is False
Пример #8
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)
Пример #9
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)
Пример #10
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()
Пример #11
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()