本文整理汇总了Python中TestLib.runTests方法的典型用法代码示例。如果您正苦于以下问题:Python TestLib.runTests方法的具体用法?Python TestLib.runTests怎么用?Python TestLib.runTests使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestLib
的用法示例。
在下文中一共展示了TestLib.runTests方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCase
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import runTests [as 别名]
import TestLib
exeName = os.path.realpath(sys.argv[0])
top_srcdir = os.path.join(os.path.dirname(exeName), "..")
top_builddir = os.getcwd()
sys.path.insert(0,top_srcdir)
sys.path.insert(0,"%s/ft-cli/" % top_srcdir)
# runs all modules TestCase() classes in files that match test*.py
if __name__ == "__main__":
testModulePath="%s/test/" % top_srcdir
moduleNames = glob.glob( "%s/test*.py" % testModulePath )
moduleNames = [ m[len(testModulePath):-3] for m in moduleNames ]
tests = []
for moduleName in moduleNames:
if "testAll" in moduleName:
continue
module = __import__(moduleName, globals(), locals(), [])
module.TestCase.top_srcdir=top_srcdir
module.TestCase.top_builddir=top_builddir
tests.append(module.TestCase)
retval = 1
if tests:
retval = TestLib.runTests( tests )
sys.exit( not retval )
示例2: _test_cb
# 需要导入模块: import TestLib [as 别名]
# 或者: from TestLib import runTests [as 别名]
# a test callback that increments a counter each time it is called
def _test_cb(cmosObj, do_update, userdata):
i = ctypes.cast(userdata, ctypes.POINTER(ctypes.c_uint16))
i[0] = i[0] + 1
return 1
int = ctypes.c_uint16(0)
cObj.registerCallback(_test_cb, ctypes.pointer(int), None)
for i in xrange(26):
# index/data ports to 0 for unit testing
b = cObj.readByte(0, 0, i)
self.assertEquals( ord('a') + i, b )
cObj.writeByte( b + ord('A') - ord('a'), 0, 0, i )
b = cObj.readByte(0, 0, i)
self.assertEquals( ord('A') + i, b )
self.assertEquals(int.value, 26)
# index port 1 (offset 512 + i) should be '0'
for i in xrange(26):
c = cObj.readByte(1, 0, i)
self.assertEquals(c, ord('0'))
if __name__ == "__main__":
import TestLib
sys.exit(not TestLib.runTests( [TestCase] ))