本文整理汇总了Python中unittest.TestSuite.addTests方法的典型用法代码示例。如果您正苦于以下问题:Python TestSuite.addTests方法的具体用法?Python TestSuite.addTests怎么用?Python TestSuite.addTests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unittest.TestSuite
的用法示例。
在下文中一共展示了TestSuite.addTests方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadTestsFromName
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def loadTestsFromName(self, name, module=None):
suite = TestSuite()
for test in findTests(name):
sys.path.insert(0, name) # python3 compatibility
suite.addTests(super(TestLoader, self).loadTestsFromName(test))
del sys.path[0] # python3 compatibility
return suite
示例2: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def suite():
import tests.sigv4_test
ts = TestSuite()
ts.addTests(tests.sigv4_test.get_test_cases())
return ts
示例3: load_tests
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def load_tests():
test_suite = TestSuite()
this_dir = os.path.dirname(__file__)
loader = TestLoader()
package_tests = loader.discover(start_dir=this_dir)
test_suite.addTests(package_tests)
return test_suite
示例4: gen_suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def gen_suite():
suite = TestSuite()
suite.addTest(suite_from_file('search_strings.txt', True))
# suite.addTest(suite_from_file('mobile_useragents.txt', True))
# suite.addTest(suite_from_file('other_useragents.txt', False))
suite.addTests(TestLoader().loadTestsFromTestCase(TestHTTPHeaders))
return suite
示例5: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [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
示例6: load_tests
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def load_tests(loader, tests, pattern):
suite = TestSuite()
for all_test_suite in defaultTestLoader.discover('.', pattern='*tests.py'):
for test_suite in all_test_suite:
suite.addTests(test_suite)
return suite
示例7: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def suite():
suite = TestSuite()
suite.addTests(
defaultTestLoader.loadTestsFromTestCase(TestSubmissionModule))
suite.addTests(
defaultTestLoader.loadTestsFromTestCase(TestSubmission))
return suite
示例8: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [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
示例9: load_tests
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def load_tests (loader, tests, pattern):
from unittest import TestSuite
from . import future, pair, source, async, limit, file, buffered, event
suite = TestSuite ()
for test in (future, pair, source, async, limit, file, buffered, event):
suite.addTests (loader.loadTestsFromModule (test))
示例10: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def suite():
suite = TestSuite()
for m in UNIT_TESTS:
suite.addTests(TestLoader().loadTestsFromName(m))
for m in DOC_TESTS:
suite.addTest(DocTestSuite(__import__(m, {}, {}, [''])))
return suite
示例11: all_tests
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def all_tests():
suite = TestSuite()
loader = TestLoader()
suite.addTests(loader.loadTestsFromTestCase(RewriterTest))
return suite
示例12: test_suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def test_suite():
from unittest import TestSuite, makeSuite
tests = []
tests.append(makeSuite(DeviceIdTest))
suite = TestSuite()
suite.addTests(tests)
return suite
示例13: TestHTMLTestRunner
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
class TestHTMLTestRunner(TestCase):
def setUp(self):
self.suite = TestSuite()
self.loader = TestLoader()
self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestPass))
self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestFail))
self.suite.addTests(self.loader.loadTestsFromModule(tests.SampleTestBasic))
self.results_output_buffer = StringIO()
HTMLTestRunner(stream=self.results_output_buffer).run(self.suite)
self.byte_output = self.results_output_buffer.getvalue()
def test_SampleTestPass(self):
output1="".join(self.byte_output.split())
output2="".join(SampleTestPass.EXPECTED_RESULT.split())
self.assertGreater(output1.find(output2),0)
@skip("Test Skipping")
def test_SampleTestSkip(self):
self.fail("This error should never be displayed")
def test_SampleTestFail(self):
output1="".join(self.byte_output.split())
output2="".join(SampleTestFail.EXPECTED_RESULT.split())
self.assertGreater(output1.find(output2),0)
def test_SampleTestBasic(self):
output1="".join(self.byte_output.split())
output2="".join(SampleTestBasic.EXPECTED_RESULT.split())
self.assertGreater(output1.find(output2),0)
示例14: suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def suite():
ts = TestSuite()
tests = [BenchMarkTest, BenchmarkModuleTest]
ts.addTests(map(makeSuite, tests))
return ts
示例15: make_test_suite
# 需要导入模块: from unittest import TestSuite [as 别名]
# 或者: from unittest.TestSuite import addTests [as 别名]
def make_test_suite():
"""Load unittests placed in pybrain/tests/unittests, then return a
TestSuite object of those."""
# [...]/pybrain/pybrain [cut] /tests/runtests.py
path = os.path.abspath(__file__).rsplit(os.sep+'tests', 1)[0]
sys.path.append(path.rstrip('pybrain'))
top_testdir = os.path.join(path, 'tests', 'unittests')
testdirs = getSubDirectories(top_testdir)
# Initialize the testsuite to add to
suite = TestSuite()
optionflags = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.IGNORE_EXCEPTION_DETAIL
for testdir in testdirs:
# All unittest modules have to start with 'test_' and have to be, of
# course, python files
module_names = [f[:-3] for f in os.listdir(testdir)
if f.startswith('test_') and f.endswith('.py')]
if not module_names:
logging.info('No tests found in %s' % testdir)
continue
# "Magically" import the tests package and its test-modules that we've
# found
test_package_path = 'pybrain.tests.unittests'
sub_path = os.path.relpath(testdir, top_testdir).split(os.sep)
test_package_path = '.'.join([test_package_path]+sub_path)
test_package = __import__(test_package_path, fromlist=module_names)
# Put the test modules in a list that can be passed to the testsuite
modules = (getattr(test_package, n) for n in module_names)
modules = [(m, missingDependencies(m)) for m in modules]
untests = [(m, md) for m, md in modules if md]
modules = [m for m, md in modules if not md]
# print(out modules that are missing dependencies)
for module, miss_dep in untests: # Mr Dep is not around, though
logging.warning('Module %s is missing dependencies: %s' % (
module.__name__, ', '.join(miss_dep)))
# print(out a list of tests that are found)
for m in modules:
logging.info('Tests found: %s' % m.__name__)
# Build up the testsuite
suite.addTests([TestLoader().loadTestsFromModule(m) for m in modules])
# Add doctests from the unittest modules to the suite
for mod in modules:
try:
suite.addTest(doctest.DocTestSuite(mod, optionflags=optionflags))
except ValueError:
# No tests found.
pass
return suite