예제 #1
0
def test_forkingadapter_call():
    run = DummyRunner()
    adapter = runner.ForkingAdapter(run)
    fork_mock = patch("tools.base.runner.ForkingAdapter.subproc_run")

    with fork_mock as m_fork:
        assert (adapter("arg1",
                        "arg2",
                        "arg3",
                        kwa1="foo",
                        kwa2="bar",
                        kwa3="baz") == m_fork.return_value)
    assert (list(m_fork.call_args) == [('arg1', 'arg2', 'arg3'), {
        'kwa1': 'foo',
        'kwa2': 'bar',
        'kwa3': 'baz'
    }])
예제 #2
0
def test_forkingadapter_subproc_run(patches, args, cwd, capture_output):
    adapter = runner.ForkingAdapter(DummyRunner())
    patched = patches("subprocess.run",
                      ("Runner.path", dict(new_callable=PropertyMock)),
                      prefix="tools.base.runner")

    with patched as (m_run, m_path):
        kwargs = {}
        if cwd != "NONE":
            kwargs["cwd"] = cwd
        if capture_output != "NONE":
            kwargs["capture_output"] = capture_output
        assert adapter.subproc_run(*args, **kwargs) == m_run.return_value

    expected = {'capture_output': True, 'cwd': cwd}
    if capture_output is False:
        expected["capture_output"] = False
    if cwd == "NONE":
        expected["cwd"] = m_path.return_value
    assert (list(m_run.call_args) == [args, expected])
예제 #3
0
 def fork(self):
     return runner.ForkingAdapter(self)
예제 #4
0
def test_forkingadapter_constructor():
    run = DummyRunner()
    adapter = runner.ForkingAdapter(run)
    assert adapter.context == run
예제 #5
0
def test_forkingadapter_constructor():
    _runner = DummyRunner()
    adapter = runner.ForkingAdapter(_runner)
    assert adapter.context == _runner