示例#1
0
 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()
示例#2
0
 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)")
示例#3
0
 def test__getcol_global_dir(self):
     x = self.tmpdir.ensure("a", dir=1)
     config = py.test.config._reparse([x])
     col = config._getcollector(x)
     assert isinstance(col, py.test.collect.Directory)
     print col.listchain()
     assert col.name == 'a'
     assert col.parent is None
     assert col._config is config 
示例#4
0
 def test__getcol_global_file(self):
     x = self.tmpdir.ensure("x.py")
     config = py.test.config._reparse([x])
     col = config._getcollector(x)
     assert isinstance(col, py.test.collect.Module)
     assert col.name == 'x.py'
     assert col.parent.name == self.tmpdir.basename 
     assert col.parent.parent is None
     for col in col.listchain():
         assert col._config is config