本文整理汇总了Python中unittest.suite.TestSuite.addTest方法的典型用法代码示例。如果您正苦于以下问题:Python TestSuite.addTest方法的具体用法?Python TestSuite.addTest怎么用?Python TestSuite.addTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.suite.TestSuite
的用法示例。
在下文中一共展示了TestSuite.addTest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(VolumeServerIntegration(
"test_can_create_volume_server_from_deactivated_image"))
suite.addTest(VolumeServerIntegration(
"test_can_create_volume_server_from_reactivated_image"))
return suite
示例2: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(DeactivateReactivateBlockStorage(
'test_create_volume_from_deactivated_image_invalid'))
suite.addTest(DeactivateReactivateBlockStorage(
'test_create_volume_from_reactivated_image'))
return suite
示例3: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(ResizeServerVolumeIntegrationTest(
"test_resize_server_and_confirm"))
suite.addTest(ResizeServerVolumeIntegrationTest(
"test_volume_attached_after_resize"))
return suite
示例4: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(MultipleContainersTest(
"test_custom_container_present_after_image_create"))
suite.addTest(MultipleContainersTest(
"test_custom_container_present_after_image_delete"))
return suite
示例5: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(GlanceScrubberTest(
"test_chunks_present_after_image_create"))
suite.addTest(GlanceScrubberTest(
"test_chunks_deleted_after_image_delete"))
return suite
示例6: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(CreateServerVolumeIntegrationTest(
"test_attach_volume_to_server"))
suite.addTest(CreateServerVolumeIntegrationTest(
"test_format_and_mount_volume"))
return suite
示例7: runTest
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def runTest():
suite = TestSuite()
suite.addTest(self.test)
runner = _TestRunner()
result = runner.run(suite)
if result.err is not None:
desc = result.err[1].message + "\n" + "".join(traceback.format_tb(result.err[2]))
raise Exception(desc)
示例8: build_suite
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def build_suite(self, *args, **kwargs):
suite = super(CustomizedRunner, self).build_suite(*args, **kwargs)
filtered = TestSuite()
for test in suite:
testname = str(test)
if '.tests.' in testname and self.package in testname:
filtered.addTest(test)
return filtered
示例9: _runTest
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def _runTest(self):
"""method used to run a test."""
suite = TestSuite()
suite.addTest(self.test)
runner = _TestRunner()
result = runner.run(suite)
if result.err is not None:
desc = str(result.err) + "\n" + \
"".join(traceback.format_tb(result.err[2]))
raise Exception(desc)
示例10: _get_suite
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def _get_suite(self, test_labels, discover_kwargs, extra_tests, methods):
suite = TestSuite()
for label in test_labels:
kwargs = discover_kwargs.copy()
tests = None
label_as_path = os.path.abspath(label)
# if a module, or "module.ClassName[.method_name]", just run those
if not os.path.exists(label_as_path):
tests = self.test_loader.loadTestsFromName(label)
elif os.path.isdir(label_as_path) and not self.top_level:
# Try to be a bit smarter than unittest about finding the
# default top-level for a given directory path, to avoid
# breaking relative imports. (Unittest's default is to set
# top-level equal to the path, which means relative imports
# will result in "Attempted relative import in non-package.").
# We'd be happy to skip this and require dotted module paths
# (which don't cause this problem) instead of file paths (which
# do), but in the case of a directory in the cwd, which would
# be equally valid if considered as a top-level module or as a
# directory path, unittest unfortunately prefers the latter.
top_level = label_as_path
while True:
init_py = os.path.join(top_level, '__init__.py')
if os.path.exists(init_py):
try_next = os.path.dirname(top_level)
if try_next == top_level:
# __init__.py all the way down? give up.
break
top_level = try_next
continue
break
kwargs['top_level_dir'] = top_level
if not (tests and tests.countTestCases()):
# if no tests found, it's probably a package; try discovery
tests = self.test_loader.discover(start_dir=label, **kwargs)
# make unittest forget the top-level dir it calculated from this
# run, to support running tests from two different top-levels.
self.test_loader._top_level_dir = None
tests = self.get_tests_defined_in_methods_or_none(tests, methods)
if tests:
suite.addTests(tests)
for test in extra_tests:
suite.addTest(test)
return suite
示例11: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
"""
Generate a test suite of tests from several test classes.
Specifically:
- test_volume_attached_after_migration from
LiveMigratateServerWithVolumeTests
- test_format_and_mount_disks, test_live_migrate_server,
test_verify_ephemeral_disks_mounted from
LiveMigratateServerWithVolumeTests
These tests are added in a specific order to the load_tests method to
enforce run order. This run order will ensure that the instance
generated during LiveMigratateServerWithVolumeTests setUpClass
is setup and then migrated in the appropriate order for these tests.
"""
suite = TestSuite()
# During the LiveMigratateServerWithVolumeTests setup an instance is
# created that will be used for the tests in this test module
suite.addTest(LiveMigratateServerWithVolumeTests(
"test_format_and_mount_disks"))
# This test performs a live migrate on the instance
suite.addTest(LiveMigratateServerWithVolumeTests(
"test_live_migrate_server"))
suite.addTest(LiveMigratateServerWithVolumeTests(
"test_verify_ephemeral_disks_mounted"))
suite.addTest(LiveMigratateServerWithVolumeTests(
"test_volume_attached_after_migration"))
return suite
示例12: suite
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def suite():
suite = TestSuite()
suite.addTest(SimpleKindAwareInsertTest())
suite.addTest(KindAwareInsertWithParentTest())
suite.addTest(SimpleKindAwareQueryTest())
suite.addTest(AncestorQueryTest())
return suite
示例13: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(DeactivateReactivateServers(
'test_deactivate_snapshot_image'))
suite.addTest(DeactivateReactivateServers(
'test_create_server_from_deactivated_image_invalid'))
suite.addTest(DeactivateReactivateServers(
'test_reactivate_snapshot_image'))
suite.addTest(DeactivateReactivateServers(
'test_create_server_from_reactivated_image'))
return suite
示例14: creat
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [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: load_tests
# 需要导入模块: from unittest.suite import TestSuite [as 别名]
# 或者: from unittest.suite.TestSuite import addTest [as 别名]
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTest(LiveMigratationServerTests(
"test_format_and_mount_disks"))
suite.addTest(LiveMigratationServerTests(
"test_live_migrate_server"))
suite.addTest(LiveMigratationServerTests(
"test_verify_ephemeral_disks_mounted"))
return suite