Esempio n. 1
0
def test_process_output_shell(command: Union[str, List[str]]) -> None:
    """Start process, check output and shut it down with shell set to True."""
    executor = SimpleExecutor(command, shell=True)
    executor.start()

    assert executor.output().read().strip() == "foobar"
    executor.stop()
Esempio n. 2
0
def test_process_output_shell(command):
    """Start process, check output and shut it down with shell set to True."""
    executor = SimpleExecutor(command, shell=True)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Esempio n. 3
0
def test_stop_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT passed to stop."""
    executor = SimpleExecutor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.stop(sig=signal.SIGQUIT)
    assert executor.running() is False
Esempio n. 4
0
def test_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT."""
    executor = SimpleExecutor(SLEEP_300, sig_stop=signal.SIGQUIT)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False
Esempio n. 5
0
def test_process_output(command):
    """Start process, check output and shut it down."""
    executor = SimpleExecutor(command)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Esempio n. 6
0
def test_process_output_shell(command):
    """Start process, check output and shut it down with shell set to True."""
    executor = SimpleExecutor(command, shell=True)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Esempio n. 7
0
def test_process_output(command: Union[str, List[str]]) -> None:
    """Start process, check output and shut it down."""
    executor = SimpleExecutor(command)
    executor.start()

    assert executor.output().read() == "foobar\n"
    executor.stop()
Esempio n. 8
0
def test_stop_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT passed to stop."""
    executor = SimpleExecutor(sleep_300)
    executor.start()
    assert executor.running() is True
    executor.stop(sig=signal.SIGQUIT)
    assert executor.running() is False
Esempio n. 9
0
def test_process_output(command):
    """Start process, check output and shut it down."""
    executor = SimpleExecutor(command)
    executor.start()

    assert executor.output().read() == 'foobar'
    executor.stop()
Esempio n. 10
0
def test_custom_signal_stop():
    """Start process and shuts it down using signal SIGQUIT."""
    executor = SimpleExecutor(SLEEP_300, stop_signal=signal.SIGQUIT)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False
Esempio n. 11
0
def test_stop_custom_exit_signal_stop():
    """Start process and expect it to finish with custom signal."""
    executor = SimpleExecutor('false', shell=True)
    executor.start()
    # false exits instant, so there should not be a process to stop
    executor.stop(sig=signal.SIGQUIT, exp_sig=3)
    assert executor.running() is False
Esempio n. 12
0
def test_running_process(command):
    """Start process and shuts it down."""
    executor = SimpleExecutor(command)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False

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

    # check proper __str__ and __repr__ rendering:
    assert 'SimpleExecutor' in repr(executor)
    assert 'sleep 300' in str(executor)
Esempio n. 14
0
def test_running_process(command: Union[str, List[str]]) -> None:
    """Start process and shuts it down."""
    executor = SimpleExecutor(command)
    executor.start()
    assert executor.running() is True
    executor.stop()
    assert executor.running() is False

    # check proper __str__ and __repr__ rendering:
    assert "SimpleExecutor" in repr(executor)
    assert SLEEP_300 in str(executor)
Esempio n. 15
0
def test_stopping_not_yet_running_executor():
    """
    Test if SimpleExecutor can be stopped even it was never running.

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

    We must make sure that it's possible to call .stop() and SimpleExecutor
    will not raise any exception and .start() can be called afterwards.
    """
    executor = SimpleExecutor(sleep_300)
    executor.stop()
    executor.start()
    assert executor.running() is True
    executor.stop()
Esempio n. 17
0
def test_stop_custom_exit_signal_stop():
    """Start process and expect it to finish with custom signal."""
    executor = SimpleExecutor("false", shell=True)
    executor.start()
    # false exits instant, so there should not be a process to stop
    retry(lambda: executor.stop(stop_signal=signal.SIGQUIT,
                                expected_returncode=-3))
    assert executor.running() is False