def test_config_make_and__mergerepr(): tmp = py.test.ensuretemp("reprconfig1") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write("x=1") config = py.test.config._reparse([tmp]) repr = config._makerepr(conftestnames=['x']) config.option.verbose = 42 repr2 = config._makerepr(conftestnames=[], optnames=['verbose']) config = py.test.config._reparse([tmp.dirpath()]) py.test.raises(KeyError, "config.getvalue('x')") config._mergerepr(repr) assert config.getvalue('x') == 1 config._mergerepr(repr2) assert config.option.verbose == 42
def test_config_rconfig(): tmp = py.test.ensuretemp("rconfigopt") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write(py.code.Source(""" import py Option = py.test.config.Option option = py.test.config.addoptions("testing group", Option('-G', '--glong', action="store", default=42, type="int", dest="gdest", help="g value.")) """)) config = py.test.config._reparse([tmp, "-G", "11"]) assert config.option.gdest == 11 repr = config._makerepr(conftestnames=[]) config = py.test.config._reparse([tmp.dirpath()]) py.test.raises(AttributeError, "config.option.gdest") config._mergerepr(repr) assert config.option.gdest == 11