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()
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()
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
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
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()
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()
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
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
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)
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)
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()
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