def test_get_collector_trail_and_back(self): a = self.tmpdir.ensure("a", dir=1) self.tmpdir.ensure("a", "__init__.py") x = self.tmpdir.ensure("a", "trail.py") config = py.test.config._reparse([x]) col = config._getcollector(x) trail = config.get_collector_trail(col) assert len(trail) == 2 assert trail[0] == a.relto(config.topdir) assert trail[1] == ('trail.py',) col2 = config._getcollector(trail) assert col2.listnames() == col.listnames()
def test_get_collector_trail_topdir_and_beyond(self): config = py.test.config._reparse([self.tmpdir]) col = config._getcollector(config.topdir) trail = config.get_collector_trail(col) assert len(trail) == 2 assert trail[0] == '.' assert trail[1] == () col2 = config._getcollector(trail) assert col2.fspath == config.topdir assert len(col2.listchain()) == 1 col3 = config._getcollector(config.topdir.dirpath()) py.test.raises(ValueError, "config.get_collector_trail(col3)")