How to use the mirakuru.OutputExecutor function in mirakuru

To help you get started, we’ve selected a few mirakuru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ClearcodeHQ / mirakuru / tests / executors / test_output_executor.py View on Github external
def test_executor_waits_for_process_output():
    """Check if executor waits for specified output."""
    command = 'bash -c "sleep 2 && echo foo && echo bar && sleep 100"'
    executor = OutputExecutor(command, 'foo', timeout=10).start()

    assert executor.running() is True
    # foo has been used for start as a banner.
    assert executor.output().readline() == 'bar\n'
    executor.stop()

    # check proper __str__ and __repr__ rendering:
    assert 'OutputExecutor' in repr(executor)
    assert 'foo' in str(executor)
github ClearcodeHQ / mirakuru / tests / executors / test_output_executor.py View on Github external
def test_executor_dont_start():
    """Executor should not start."""
    command = 'bash -c "sleep 2 && echo foo && echo bar && sleep 100"'
    executor = OutputExecutor(command, 'foobar', timeout=3)
    with pytest.raises(TimeoutExpired):
        executor.start()

    assert executor.running() is False
github ClearcodeHQ / mirakuru / tests / executors / test_output_executor.py View on Github external
def test_executor_waits_for_process_err_output():
    """Check if executor waits for specified error output."""
    command = 'bash -c "sleep 2 && >&2 echo foo && >&2 echo bar && sleep 100"'
    executor = OutputExecutor(
        command, 'foo', timeout=10, stdin=None, stderr=subprocess.PIPE
    ).start()

    assert executor.running() is True
    # foo has been used for start as a banner.
    assert executor.err_output().readline() == 'bar\n'
    executor.stop()

    # check proper __str__ and __repr__ rendering:
    assert 'OutputExecutor' in repr(executor)
    assert 'foo' in str(executor)