本文整理汇总了Python中unittest.TestLoader.loadTestsFromTestCase方法的典型用法代码示例。如果您正苦于以下问题:Python TestLoader.loadTestsFromTestCase方法的具体用法?Python TestLoader.loadTestsFromTestCase怎么用?Python TestLoader.loadTestsFromTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestLoader
的用法示例。
在下文中一共展示了TestLoader.loadTestsFromTestCase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def test_all():
loader = TestLoader()
suite = TestSuite()
suite.addTests(loader.loadTestsFromTestCase(TestLocale))
suite.addTests(loader.loadTestsFromTestCase(TestExtract))
suite.addTests(loader.loadTestsFromTestCase(TestMerge))
return suite
示例2: run
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def run():
loader = TestLoader()
suite = TestSuite((
loader.loadTestsFromTestCase(UtilsTests),
loader.loadTestsFromTestCase(Tests)
))
runner = TextTestRunner(verbosity = 2)
runner.run(suite)
示例3: loadTestCases
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def loadTestCases(self):
loader = TestLoader()
selector = QTestLoader()
if selector.exec_():
self.cases[:] = []
for case in selector.selected:
self.cases.extend(loader.loadTestsFromTestCase(case))
示例4: TestGroup
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
class TestGroup(object):
def __init__(self, name, classnames=None, groupSetUp=lambda:None, groupTearDown=lambda:None):
self.name = name
self._classes = {}
for classname in (classnames or []):
self._loadClass(classname)
self._loader = TestLoader()
self.setUp = groupSetUp
self.tearDown = groupTearDown
def _loadClass(self, classname):
moduleName, className = classname.rsplit('.', 1)
cls = getattr(__import__(moduleName, globals(), locals(), [className]), className)
self._classes[className] = cls
def createSuite(self, testnames=None):
if not testnames:
testnames = sorted(self._classes.keys())
suite = TestSuite()
for testname in testnames:
testcase = testname.split('.')
testclass = self._classes.get(testcase[0], None)
if not testclass:
continue
if len(testcase) == 1:
suite.addTest(self._loader.loadTestsFromTestCase(testclass))
else:
suite.addTest(self._loader.loadTestsFromName(testcase[1], testclass))
return suite
示例5: test_suite
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def test_suite():
loader = TestLoader()
tests = loader.loadTestsFromTestCase(PrincipalAnnotationTests)
import zope.app.principalannotation
tests.addTest(doctest.DocTestSuite(zope.app.principalannotation))
return tests
示例6: suite
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def suite():
"""Suite of TestCases for Django"""
suite = TestSuite()
loader = TestLoader()
test_cases = (ManagersTestCase, EntryTestCase,
LoadModelClassTestCase, SignalsTestCase,
EntryHtmlContentTestCase, CategoryTestCase,
ZinniaViewsTestCase, ZinniaFeedsTestCase,
ZinniaSitemapsTestCase, ComparisonTestCase,
DirectoryPingerTestCase, ExternalUrlsPingerTestCase,
TemplateTagsTestCase, QuickEntryTestCase,
URLShortenerTestCase, EntryCommentModeratorTestCase,
ZinniaCustomDetailViews, SpamCheckerTestCase,
EntryAdminTestCase, CategoryAdminTestCase,
MixinTestCase, LongEnoughTestCase,
AuthorTestCase, FlagsTestCase,
AuthorListFilterTestCase, CategoryListFilterTestCase,
TranslatedURLsTestCase, EntryAbsoluteUrlTestCase,
MarkupsTestCase, FailImportMarkupTestCase,
PingBackTestCase, MetaWeblogTestCase,
HTMLPreviewTestCase,
EntryAdminFormTestCase, CategoryAdminFormTestCase,
MPTTModelChoiceIteratorTestCase,
MPTTModelMultipleChoiceFieldTestCase,
MPTTFilteredSelectMultipleTestCase
)
for test_class in test_cases:
tests = loader.loadTestsFromTestCase(test_class)
suite.addTests(tests)
return suite
示例7: suite
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def suite():
"""Suite of TestCases for Django"""
suite = TestSuite()
loader = TestLoader()
test_cases = (ManagersTestCase, EntryTestCase,
EntryGetBaseModelTestCase, SignalsTestCase,
EntryHtmlContentTestCase, CategoryTestCase,
ZinniaViewsTestCase, ZinniaFeedsTestCase,
ZinniaSitemapsTestCase, ComparisonTestCase,
DirectoryPingerTestCase, ExternalUrlsPingerTestCase,
TemplateTagsTestCase, QuickEntryTestCase,
URLShortenerTestCase, EntryCommentModeratorTestCase,
ZinniaCustomDetailViews, SpamCheckerTestCase,
EntryAdminTestCase, CategoryAdminTestCase,
MixinTestCase, LongEnoughTestCase,
AuthorTestCase)
if 'django_xmlrpc' in settings.INSTALLED_APPS:
test_cases += (PingBackTestCase, MetaWeblogTestCase)
for test_class in test_cases:
tests = loader.loadTestsFromTestCase(test_class)
suite.addTests(tests)
return suite
示例8: all_tests
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def all_tests():
suite = TestSuite()
loader = TestLoader()
suite.addTests(loader.loadTestsFromTestCase(RewriterTest))
return suite
示例9: build_suite
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def build_suite(self, test_labels, extra_tests=None, **kwargs):
suite = TestSuite()
loader = TestLoader()
for fname in _get_module_names('.'):
module = _import(_to_importable_name(fname))
for test_case in _get_module_testcases(module):
suite.addTests(loader.loadTestsFromTestCase(test_case))
return reorder_suite(suite, (TestCase,))
示例10: test_data_cleaned_up
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def test_data_cleaned_up(self):
user_collection.remove()
company_collection.remove()
loader = TestLoader()
suite = loader.loadTestsFromTestCase(TestUnittestSupport.TestTestCase)
result = TestResult()
suite.run(result)
self.assertTrue(result.wasSuccessful(), result)
self.assertEquals(user_collection.count(), 0)
self.assertEquals(company_collection.count(), 0)
示例11: testSuiteFromTCs
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def testSuiteFromTCs(*tcs):
loader = TestLoader()
for tc in tcs:
# skip AxiLiteEndpointTC because we need one to test original methods
# from SimTestCase
if issubclass(tc, SimTestCase) and tc is not AxiLiteEndpointTC:
tc.runSim = runSimWithoutLog
tc._multiprocess_can_split_ = True
loadedTcs = [loader.loadTestsFromTestCase(tc) for tc in tcs]
suite = TestSuite(loadedTcs)
return suite
示例12: suite
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def suite():
unit_test_cases = ()
integration_test_cases = (
URLSmokeTest,
AuthMiddleWareTest,
RequestCreateTest, RequestDetailsTest, ProfileDetailsTest, RequestListTest,
TestAuthentication
)
all_test_cases = unit_test_cases + integration_test_cases
test_loader = TestLoader()
tests = [test_loader.loadTestsFromTestCase(case) for case in all_test_cases]
return TestSuite(tests)
示例13: combine
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def combine(*args):
"combine given TestCase classes and suite objects into a new suite"
loader = TestLoader()
suites = []
for arg in args:
if isinstance(arg, TestSuite):
suites.append(arg)
elif issubclass(arg, RealTestCase):
suites.append(loader.loadTestsFromTestCase(arg))
else:
msg = "combine: bad arg type: %s <%s>" % (arg, type(arg))
raise AssertionError(msg)
return TestSuite(suites)
示例14: creat
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def creat():
loadcase=TestLoader()
testsuite=[]
suite1=TestSuite()
suite2=TestSuite()
caseclass_dict={}
def backcount(d):
n=0
for i in d.values():
n+=i
return n
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
classcase_dict=caseclass_count(backcaselist(dirs+'/bank_case'))
case_and_count_list=back_list(classcase_dict)
sort_case=SelectSort(case_and_count_list)
print sort_case
for i in range(len(sort_case)):
if i%2==0:
suite1.addTest(loadcase.loadTestsFromTestCase([x for x in sort_case[i].keys()][0]))
[x for x in sort_case[i].keys()][0].remoteip='http://172.17.2.136:3344/wd/hub'
else:
suite2.addTest(loadcase.loadTestsFromTestCase([x for x in sort_case[i].keys()][0]))
[x for x in sort_case[i].keys()][0].remoteip='http://172.17.2.57:3344/wd/hub'
print 'suite1',suite1
print 'suite2',suite2
testsuite.append(suite1)
testsuite.append(suite2)
return testsuite
示例15: test_all
# 需要导入模块: from unittest import TestLoader [as 别名]
# 或者: from unittest.TestLoader import loadTestsFromTestCase [as 别名]
def test_all():
loader = TestLoader()
suites = [
loader.loadTestsFromTestCase(TestRole),
loader.loadTestsFromTestCase(TestIP),
loader.loadTestsFromTestCase(TestHost),
loader.loadTestsFromTestCase(TestRoleMap),
loader.loadTestsFromTestCase(TestApi),
loader.loadTestsFromTestCase(TestHostsOutput),
loader.loadTestsFromTestCase(TestValidator),
]
testsuites = TestSuite(suites)
runner = TextTestRunner()
runner.run(testsuites)