I want to add few tests on how my cli app handles different signals (SIGTERM
, etc). And I am using native testing solution click.testing.CliRunner
alongside of pytest.
Test looks pretty standard and simple
def test_breaking_process(server, runner):
address = server.router({'^/$': Page("").exists().slow()})
runner = CliRunner(mix_stderr=True)
args = [address, '--no-colors', '--no-progress']
result = runner.invoke(main, args)
assert result.exit_code == 0
And here I am stuck, how could I send SIGTERM
to process in runner.invoke
? I see no problem to do it if I use e2e tests (calling executable and not CLIrunner), but I would like to try to implement this (at least able to send os.kill)
is there a way to do it?