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'
def test_readconfig_preset(tmpdir): p181 = Proc() p181.runner = 'xyz' config = Config() cfile = tmpdir / 'test_readconfig_preset.ini' cfile.write_text(""" [xyz] runner: sge forks: 50 """) config._load(cfile) p181._readConfig('', config) assert p181.runner == 'sge' assert p181.forks == 50 assert p181.config.runner == 'xyz'