Ejemplo n.º 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
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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()