Ejemplo n.º 1
0
def test_runcmd(tmpdir, caplog):
    p19 = Proc()
    p19.props.template = TemplateLiquid
    p19._runCmd('pre')
    assert 'Running ' not in caplog.text

    p19.preCmd = 'echo "Hello world!"'
    p19._runCmd('before')
    assert 'Running <beforeCmd> ...' in caplog.text
    assert 'Hello world!' in caplog.text

    p19.postCmd = 'nosuchcommand'
    with pytest.raises(ProcRunCmdError):
        p19._runCmd('post')
Ejemplo n.º 2
0
def test_proc_setattr(tmpdir, caplog):
    p3 = Proc()
    with pytest.raises(ProcAttributeError):
        p3.x = 1
    p3.preCmd = 'ls'
    assert 'beforeCmd' in p3.sets

    p4 = Proc()
    ps = ProcSet(p4)
    p3.depends = p4
    assert p3.depends == [p4]
    p3.depends = [p4], ps
    assert p3.depends == [p4, ps.p4]
    assert p4.tag == 'notag'
    assert ps.p4.tag == 'notag@ps'

    with pytest.raises(ProcAttributeError):
        p3.depends = p3

    with pytest.raises(ProcAttributeError):
        p3.depends = object()

    p3.script = 'file:%s' % Path(__file__).name
    assert p3.config.script == 'file:%s' % Path(__file__).resolve()

    p31 = Proc(script='file:%s' % Path(__file__).name)
    assert p31.config.script == 'file:%s' % Path(__file__).resolve()

    with pytest.raises(ProcAttributeError):
        p3.script = 'file:nosuchfile'

    p3.args = {'a': 1}
    assert p3.args.a == 1

    p3.input = 'a, b'
    p3.input = [1, 2]
    assert p3.config.input == {'a, b': [1, 2]}

    p3.input = {'a': [1], 'b': [2]}
    caplog.clear()
    p3.input = [3, 4]
    assert 'Previous input is a dict with multiple keys and key order may be changed.' in caplog.text
    assert 'Now the key order is:' in caplog.text

    p3.runner = 'sge'
    assert p3.config.runner == 'sge'
    assert p3.props.runner == 'sge'

    with pytest.raises(ProcAttributeError):
        p3.tag = 'a@b'