예제 #1
0
파일: test_proc.py 프로젝트: makerwei/PyPPL
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'
예제 #2
0
def test_buildprocvars(tmpdir, caplog):
    p11 = Proc()
    p11.args = {'a': 1}
    p11._buildProcVars()
    assert 'p11: a      => 1' in caplog.text
    assert 'p11: runner => local' in caplog.text
    assert 'p11: size   => 0' in caplog.text
    assert 'exdir' not in caplog.text
    assert p11.procvars['args'] is p11.args

    p11.config.args = {'a': 1}
    p11.exdir = 'abc'
    caplog.clear()
    p11._buildProcVars()
    assert 'p11: exdir  => abc' in caplog.text
    assert p11.procvars['args'] == p11.args
    assert p11.procvars['args'] is not p11.args