我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用doctest.DocFileTest()。
def handleFile(self, event): path = event.path[len(TOPDIR)+1:] if len(self.patterns) > 0: for pattern in self.patterns: if re.search(pattern, path): break else: # Skip this doctest. return base, ext = os.path.splitext(path) if ext != '.rst': return test = doctest.DocFileTest( path, package='ubuntu_image', optionflags=FLAGS, setUp=setup, tearDown=teardown) # Suppress the extra "Doctest: ..." line. test.shortDescription = lambda: None event.extraTests.append(test)
def doDoctestSuite(self, module): log = [] doctest.DocFileTest( 'xyz.txt', package=module, module_relative=True, globs=locals() ).run() self.assertEqual(log,[True])