- def collectTests(self):
- tests=[]
- if self.path:
- sys.path.insert(0,self.path)
- entries = os.listdir(self.path)
- entries.sort()
- for item in entries:
- if (item[0] == '.'
- or item in self.ignore
- or not testMatch.search(item)):
- continue
- item_path = os.path.abspath(os.path.join(self.path,item))
- if os.path.isfile(item_path):
- root, ext = os.path.splitext(item)
- if ext != '.py':
- continue
- name="%s.%s" % (self.package.__name__,root)
- mod=self._import(name)
- tests.append(ModuleTestSuite(mod))
- elif os.path.isdir(item_path):
- init = os.path.abspath(os.path.join(item_path,'__init__.py'))
- if os.path.isfile(init):
- name="%s.%s" % (self.package.__name__,item)
- package=self._import(name)
- if package:
- tests.append(TestPackageSuite(package))
- else:
- tests.append(TestDirectorySuite(item_path))
- sys.path.remove(self.path)
- return tests
+ def importdir(self,item,path):
+ init = os.path.abspath(os.path.join(path,'__init__.py'))
+ if os.path.isfile(init):
+ name="%s.%s" % (self.package.__name__,item)
+ package=self._import(name)
+ if package:
+ return TestPackageSuite(package)
+ else:
+ return TestDirectorySuite(path)