本文整理汇总了Python中unittest.getTestCaseNames函数的典型用法代码示例。如果您正苦于以下问题:Python getTestCaseNames函数的具体用法?Python getTestCaseNames怎么用?Python getTestCaseNames使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTestCaseNames函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: suite
def suite():
testsuite = unittest.TestSuite()
test_names = unittest.getTestCaseNames(TestAverage, "test")
for test in test_names:
testsuite.addTest(TestAverage(test))
test_names = unittest.getTestCaseNames(TestAverageMonitorName, "test")
for test in test_names:
testsuite.addTest(TestAverageMonitorName(test))
return testsuite
开发者ID:jonwright,项目名称:pyFAI,代码行数:11,代码来源:test_average.py
示例2: make_suite
def make_suite(vendor, testcase, factory, mask=None):
clz = __imp__(testcase.frm, testcase.impt)
caseNames = filter(lambda x, i=testcase.ignore: x not in i, unittest.getTestCaseNames(clz, "test"))
if mask is not None:
caseNames = filter(lambda x, mask=mask: x == mask, caseNames)
tests = [clz(caseName, vendor, factory) for caseName in caseNames]
return unittest.TestSuite(tests)
开发者ID:paulgay,项目名称:crf_dia_ident,代码行数:7,代码来源:runner.py
示例3: _add_all_tests
def _add_all_tests(self):
suite_list = [[t, unittest.getTestCaseNames(eval(t), 'test')]
for t in self.ALL_TESTS]
for sg in suite_list:
for tc in sg[1]:
self.suite.addTests([
unittest.defaultTestLoader.loadTestsFromName(sg[0]+"."+tc)])
开发者ID:pculture,项目名称:unisubs-testing,代码行数:7,代码来源:test_withHTMLoutput.py
示例4: caseclass_count
def caseclass_count(caselist):
print 'dir caselist',caselist
for casename in caselist:
module=loadcase._get_module_from_name(casename)
for name in dir(module):
obj = getattr(module,name)
if isinstance(obj, type) and issubclass(obj, case.TestCase):
modeltestcases_list=getTestCaseNames(obj,'test')
caseclass_dict[obj]=len(modeltestcases_list)
return caseclass_dict
开发者ID:dhaibo1986,项目名称:PythonWork,代码行数:10,代码来源:all_test.py
示例5: suite
def suite():
suite = unittest.TestSuite()
tclasses = [
FindPathDirsTestCase,
ScannerTestCase,
BaseTestCase,
SelectorTestCase,
CurrentTestCase,
ClassicTestCase,
ClassicCPPTestCase,
]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
suite.addTests(list(map(tclass, names)))
return suite
开发者ID:jmatt,项目名称:scons,代码行数:15,代码来源:ScannerTests.py
示例6: loadTestsFromTestCase
def loadTestsFromTestCase(testCaseClass, *args, **kwargs):
testCaseNames = unittest.getTestCaseNames(testCaseClass, 'test_')
return unittest.TestSuite(map(lambda n : testCaseClass(n, *args, **kwargs), testCaseNames))
开发者ID:Audiarto,项目名称:ZeroTierOne,代码行数:3,代码来源:tuntap_tests.py
示例7: Foo
"""
foo = Foo()
foo.parent = foo
foo.constructor = foo.__init__
def leak_frame():
frame = inspect.currentframe()
leak_frame()
del foo
g = GarbageGraph()
try:
g.render("garbage.eps")
g.render("garbage.eps", unflatten=True)
except OSError:
# Graphviz not installed.
pass
else:
os.unlink("garbage.eps")
if __name__ == "__main__":
suite = unittest.TestSuite()
tclasses = [GarbageTestCase]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, "test_")
suite.addTests(map(tclass, names))
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
开发者ID:robbiehinch,项目名称:pympler,代码行数:30,代码来源:test_garbage.py
示例8:
r = obj.value()
assert r == 1, r
r = obj.value()
assert r == 1, r
assert fv1.calls == 1, fv1.calls
assert fv2.calls == 0, fv2.calls
c = obj.get_memoizer_counter('value')
assert c.hit == 3, c.hit
assert c.miss == 1, c.miss
if __name__ == "__main__":
suite = unittest.TestSuite()
tclasses = [
CountDictTestCase,
CountValueTestCase,
]
for tclass in tclasses:
names = unittest.getTestCaseNames(tclass, 'test_')
suite.addTests(list(map(tclass, names)))
TestUnit.run(suite)
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
开发者ID:andrewyoung1991,项目名称:scons,代码行数:30,代码来源:MemoizeTests.py
示例9: __init__
def __init__(self, include="", exclude="", tests=""):
# error checking
if include != "" and exclude != "":
raise ValueError("include and exclude arguments are mutually exclusive")
# TODO: could this become a simple os.listdir(".")?
_rootdir = os.path.abspath(sys.path[0])
if not os.path.isdir(_rootdir):
_rootdir = os.path.dirname(_rootdir)
self.rootdir = _rootdir # to come in handy later
# a dict of all possible test modules that could be run
# ASSUME: each module name is unique not solely because of case
_module_names = {}
for _name in [ n[:-3] for n in os.listdir(self.rootdir)
if n.startswith("test") and n.endswith(".py") ]:
_module_names[ _name.lower() ] = _name
# make the include/exclude/tests lists
_module_specs = None
_spec_type = None
_test_specs = None
if include != "":
_module_specs = self._clean_listify(include)
_spec_type = "include"
elif exclude != "":
_module_specs = self._clean_listify(exclude)
_spec_type = "exclude"
if tests != "":
_test_specs = self._clean_listify(tests, False)
# make sure they all exist
if _module_specs != None: # TODO: got to be a better place to put this
for _mod in _module_specs:
if not _module_names.has_key(_mod.lower()):
parser.error("Module %s not found under test" % (_mod))
# now import the modules
if _module_specs == None:
self.modules = [ __import__(name) for name in _module_names.values() ]
elif _spec_type == "include":
self.modules = [ __import__(name) for name in _module_specs ]
elif _spec_type == "exclude":
self.modules = [ __import__(name) for name in _module_names.values()
if name not in _module_specs ]
# convert modules into suites
self.suites = []
for module in self.modules:
_classname = module.__name__[4:] + "Test"
_class = module.__getattribute__(_classname)
# build test suite (whether or not --tests are specified)
if _test_specs == None:
_suite = unittest.makeSuite(_class)
else:
_suite = unittest.TestSuite()
for _test_name in unittest.getTestCaseNames(_class,"test"):
for _test in _test_specs:
_docstr = getattr(_class, _test_name).__doc__
if _test_name.lower().find(_test.lower()) != -1 or \
_docstr != None and _docstr.lower().find(_test.lower()) != -1:
_suite.addTest(_class(_test_name))
break
# filter out tests that shouldn't be run in subclasses
_tests = _suite._tests
for _t in _tests:
# TODO: pull logic into wxtest
# or use the version of unittest instead
if sys.version_info[0:2] >= (2,5):
_mname = _t._testMethodName
else:
_mname = _t._TestCase__testMethodName
if _mname.find('_wx') != -1:
# grab the class: everything between '_wx' and 'Only' at the end
restriction = _mname[_mname.find('_wx')+3:-4]
if not _class.__name__.startswith(restriction):
#print "filtered: %s (class=%s)" % (mname,_class.__name__)
_tests.remove(_t)
# if suite is non-empty...
if _suite.countTestCases() > 0:
# add it to the list of suites :-)
self.suites.append(_suite)
开发者ID:Unicorn9504,项目名称:Unicorn,代码行数:82,代码来源:runUnitTests.py
示例10: _getTestCaseNames
def _getTestCaseNames(testCase):
import operator
return reduce(operator.add, [unittest.getTestCaseNames(testCase, prefix) for prefix in testPrefixes])
开发者ID:bh0085,项目名称:programming,代码行数:3,代码来源:itest.py
示例11: suite
def suite():
testsuite = unittest.TestSuite()
test_names = unittest.getTestCaseNames(TestAIWidget, "test")
for test in test_names:
testsuite.addTest(TestAIWidget(test))
return testsuite
开发者ID:jonwright,项目名称:pyFAI,代码行数:6,代码来源:test_integrate_widget.py
注:本文中的unittest.getTestCaseNames函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论