def test_config_init_direct(): tmp = py.test.ensuretemp("_initdirect") tmp.ensure("__init__.py") tmp.ensure("conftest.py").write("x=1 ; y=2") hello = tmp.ensure("test_hello.py") config = py.test.config._reparse([hello]) repr = config._makerepr(conftestnames=['x', 'y']) config2 = py.test.config._reparse([tmp.dirpath()]) config2._initialized = False # we have to do that from tests config2._initdirect(topdir=tmp.dirpath(), repr=repr) for col1, col2 in zip(config.getcolitems(), config2.getcolitems()): assert col1.fspath == col2.fspath py.test.raises(AssertionError, "config2._initdirect(None, None)") from py.__.test.config import Config config3 = Config() config3._initdirect(topdir=tmp.dirpath(), repr=repr, coltrails=[(tmp.basename, (hello.basename,))]) assert config3.getvalue('x') == 1 assert config3.getvalue('y') == 2 cols = config.getcolitems() assert len(cols) == 1 col = cols[0] assert col.name == 'test_hello.py' assert col.parent.name == tmp.basename assert col.parent.parent is None
def test_getcolitems_twodirs(self): config = py.test.config._reparse([self.tmpdir, self.tmpdir]) colitems = config.getcolitems() assert len(colitems) == 2 col1, col2 = colitems assert col1.name == col2.name assert col1.parent == col2.parent
def test_getcolitems_onedir(self): config = py.test.config._reparse([self.tmpdir]) colitems = config.getcolitems() assert len(colitems) == 1 col = colitems[0] assert isinstance(col, py.test.collect.Directory) for col in col.listchain(): assert col._config is config
def test_getcolitems_curdir_and_subdir(self): a = self.tmpdir.ensure("a", dir=1) config = py.test.config._reparse([self.tmpdir, a]) colitems = config.getcolitems() assert len(colitems) == 2 col1, col2 = colitems assert col1.name == self.tmpdir.basename assert col2.name == 'a' for col in colitems: for subcol in col.listchain(): assert col._config is config