import py mypath = py.magic.autopath().dirpath() class Directory(py.test.collect.Directory): def run(self): if self.fspath == mypath: return ['test'] return super(Directory, self).run()