当前位置: 首页>>代码示例>>Python>>正文


Python Test.enumerate方法代码示例

本文整理汇总了Python中tests.Test.enumerate方法的典型用法代码示例。如果您正苦于以下问题:Python Test.enumerate方法的具体用法?Python Test.enumerate怎么用?Python Test.enumerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.Test的用法示例。


在下文中一共展示了Test.enumerate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _runPlainR

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import enumerate [as 别名]
	def _runPlainR(self):
		""" Runs the tester in plain R mode, where it outputs the plain R version of the tests to a special file, rather than running the tests. """
		if (len(self._testRoots)!=1):
			error("When using --plainr mode, only one root can be selected");
		root = self._testRoots[0][0]
		lastFilename = ""
		outfile = None
		fileTests = 0
		print("Creating R-compatible raw tests. The following is a list of test file entered")
		print("and number of tests generated:\n")
		for t in Test.enumerate(self._testRoots, self._recursive):
			if (t.filename() != lastFilename):
				if (outfile != None):
					print("["+str(fileTests)+"]")
					outfile.close()
					fileTests = 0
				fname = os.path.join(self._plainROutput, t.filename()[len(root)+1:])
				dirname, filename = os.path.split(fname)
				print(strFormat(fname), end="")
				os.makedirs(dirname, exist_ok = True)
				outfile = open(fname, "w")
				lastFilename = t.filename()
			for c in t.commands():
				if (c.find("#! ") == 0):
					outfile.write("#! "+t.name()+"\n")
				elif (c.find("#!g") == 0):
					pass
				else:
					outfile.write(c.replace("\\\"",'"')+"\n")
			outfile.write(t.code()+"\n\n")
			fileTests += 1
		if (outfile != None):
			print("["+str(fileTests)+"]")
			outfile.close()
开发者ID:akbertram,项目名称:testr,代码行数:36,代码来源:testR.py

示例2: run

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import enumerate [as 别名]
	def run(self):
		""" Runs the test suite as specified, that is runs all tests in all files under all test roots. """
		if (self._plainROutput != None):
			return self._runPlainR()
		self._print("Initializing target %s " % self._target)
		self.target = __import__(self._target).Target(self._targetPath)
		self._print("    path:         %s" % self.target.path)
		self._print("    version:      %s" % self.target.version)
		self._print("    architecture: %s" % self.target.arch)
		tests = 0
		test_fails = 0
		run_fails = 0
		skipped = 0

		for t in Test.enumerate(self._testRoots, self._recursive):
			if (not self._reportOnlyErrors):
				print(strFormat(t.name()), end="")
			result = self._runTest(t)
			if (self._reportOnlyErrors):
				if (result[0] in (TestR.RUN_FAIL, TestR.TEST_FAIL)):
					print(strFormat(t.name()), end="")
					print(result[0])
			else:
					print(result[0])
			if (result[0] in (TestR.RUN_FAIL, TestR.TEST_FAIL)):
				print("    File: {0} [line {1}]".format(t.filename(), t.line()))
				print(strLineOffset(result[1]))
				self._print("    Code:")
				self._print(strLineOffset(t.code(), 8))
			tests += 1
			if (result[0] == TestR.RUN_FAIL):
				run_fails += 1
			elif (result[0] == TestR.TEST_FAIL):
				test_fails += 1
			elif (result[0] == TestR.NOT_RUN):
				skipped += 1

		print("\n----------------------------------------------------------------------------------------------------------\n")
		print("Total tests:    {0}".format(tests))
		print("Skipped:        {0}".format(skipped))
		print("Successful:     {0} {1}".format(tests-test_fails-run_fails-skipped, "OK" if (test_fails + run_fails == 0) else "FAIL"))
		print("Failed:         {0}".format(run_fails + test_fails))
		print("    execution:  {0}".format(run_fails))
		print("    checks:     {0}".format(test_fails))
开发者ID:akbertram,项目名称:testr,代码行数:46,代码来源:testR.py


注:本文中的tests.Test.enumerate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。