本文整理匯總了Python中unittest2.TestSuite類的典型用法代碼示例。如果您正苦於以下問題:Python TestSuite類的具體用法?Python TestSuite怎麽用?Python TestSuite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TestSuite類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: suite
def suite():
"""Returns the test suite for this module."""
result = TestSuite()
loader = defaultTestLoader
result.addTest(loader.loadTestsFromModule(test_api))
return result
示例2: test_suite
def test_suite():
suite = TestSuite()
OPTIONFLAGS = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
for testfile in ('testBrowserLayers.txt', 'testCustomizeView.txt'):
suite.addTest(FunctionalDocFileSuite(testfile,
optionflags=OPTIONFLAGS,
package="plone.app.customerize.tests",
test_class=CustomerizeFunctionalTestCase),
)
return suite
示例3: test_given
def test_given(tests):
module = sys.modules[__name__]
if tests == None:
defaultTest = None
else:
loader = TestLoader()
defaultTest = TestSuite()
tests = loader.loadTestsFromNames(tests, module)
defaultTest.addTests(tests)
main(defaultTest=defaultTest)
示例4: load_tests
def load_tests(loader, tests, pattern):
suite = TestSuite()
suite.addTests(defaultTestLoader.loadTestsFromModule(sms_user))
suite.addTests(defaultTestLoader.loadTestsFromModule(notification))
suite.addTests(defaultTestLoader.loadTestsFromModule(reply))
suite.addTests(defaultTestLoader.loadTestsFromModule(registration))
return suite
示例5: load_tests
def load_tests(loader, standard_tests, pattern):
"""Loads the tests from this module"""
suite = TestSuite()
# Only enable if you have a local server running.
# TODO: Consider automatic skipping if zmq fails to connect
# suite.addTest(loader.loadTestsFromTestCase(LiveGuessApiTestCase))
suite.addTest(loader.loadTestsFromTestCase(ClientTestCase))
suite.addTest(loader.loadTestsFromTestCase(CORSTestCase))
return suite
示例6: load_tests
def load_tests(loader, standard_tests, pattern):
"""Returns the test suite for this module."""
suite = TestSuite()
suite.addTest(loader.loadTestsFromTestCase(ModelTestCase))
suite.addTest(loader.loadTestsFromTestCase(FunctionAPITestCase))
suite.addTest(loader.loadTestsFromTestCase(FunctionEvaluationTest))
suite.addTest(loader.loadTestsFromTestCase(APITestCase))
return suite
示例7: suite
def suite():
"""Returns the test suite for this module."""
result = TestSuite()
loader = defaultTestLoader
result.addTest(loader.loadTestsFromModule(test_manager))
result.addTest(loader.loadTestsFromModule(test_search))
result.addTest(loader.loadTestsFromModule(test_validation))
result.addTest(loader.loadTestsFromModule(test_views))
return result
示例8: get_suite
def get_suite(test_names, test_dir, file_match, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, found, failfast, debug,
extended=False):
suite = TestSuite()
dir_list = os.listdir(test_dir)
# filter directory entries that don't match the file match pattern
dir_list = [f for f in dir_list if fnmatch.fnmatch(f, file_match)]
for entry in dir_list:
if not entry.endswith('.py'):
continue
if test_names and entry[:-3] not in test_names:
continue
elif not test_names:
if entry.startswith('_'):
# ignore entries starting with underscore unless specified
continue
found.add(entry[:-3])
csv_path = os.path.join(test_dir, entry.replace('.py', '.csv'))
if os.path.isfile(csv_path):
# reading the csv file now
for row in get_data(csv_path):
# row is a dictionary of variables
suite.addTest(
get_case(
test_dir, entry, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, row,
failfast=failfast, debug=debug, extended=extended
)
)
else:
suite.addTest(
get_case(
test_dir, entry, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on,
failfast=failfast, debug=debug, extended=extended
)
)
return suite
示例9: load_tests
def load_tests(loader, standard_tests, pattern):
"""Returns the test suite for this module."""
suite = TestSuite()
suite.addTest(loader.loadTestsFromTestCase(OperatorsTest))
suite.addTest(loader.loadTestsFromTestCase(QueryCreationTest))
suite.addTest(loader.loadTestsFromTestCase(SearchTest))
return suite
示例10: suite
def suite():
suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestParseLine))
suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestFuzzyMatch))
if is_win:
suite.addTest(defaultTestLoader.loadTestsFromTestCase(TestAppIdentification))
return suite
示例11: suite
def suite():
suite = TestSuite()
for test in make_json_suite():
for p in test['pass']:
datum = json.loads(json.dumps(p.datum))
suite.addTest(make_pass(test['schema'], datum))
suite.addTest(make_reserialize(test['schema'], datum))
for f in test['fail']:
datum = json.loads(json.dumps(f.datum))
suite.addTest(make_fail(test['schema'], datum))
return suite
示例12: get_suite
def get_suite(test_names, test_dir, collect_only, browser_type, device,
version, browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, failfast, debug,
custom_options=None, extended=False, saucelabs_enabled=False,
browserstack_enabled=False, vagrant_enabled=False, skip_tracking=False):
suite = TestSuite()
for case in find_cases(test_names, test_dir):
csv_path = os.path.join(test_dir, case.replace('.py', '.csv'))
if os.path.isfile(csv_path):
# reading the csv file now
for row in get_data(csv_path):
# row is a dictionary of variables
suite.addTest(
get_case(
test_dir, case, browser_type, device, version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, row, saucelabs_enabled=saucelabs_enabled,
browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled,
custom_options=custom_options, failfast=failfast,
debug=debug, extended=extended, skip_tracking=skip_tracking
)
)
else:
suite.addTest(
get_case(
test_dir, case, browser_type, device, version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on,
custom_options=custom_options, failfast=failfast,
browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled,
debug=debug, extended=extended, saucelabs_enabled=saucelabs_enabled,
skip_tracking=skip_tracking
)
)
return suite
示例13: get_suite
def get_suite(test_names, test_dir, count_only, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, failfast, debug,
extended=False):
suite = TestSuite()
if allscrewedup:
print "ENTERING get_suite \n"
print inspect.getargspec(get_suite)
print [locals()[arg] for arg in inspect.getargspec(get_suite).args]
for case in find_cases(test_names, test_dir):
csv_path = os.path.join(test_dir, case.replace('.py', '.csv'))
if os.path.isfile(csv_path):
# reading the csv file now
for row in get_data(csv_path):
# row is a dictionary of variables
suite.addTest(
get_case(
test_dir, case, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on, row,
failfast=failfast, debug=debug, extended=extended
)
)
else:
suite.addTest(
get_case(
test_dir, case, browser_type, browser_version,
browser_platform, session_name, javascript_disabled,
webdriver_remote_url, screenshots_on,
failfast=failfast, debug=debug, extended=extended
)
)
return suite
示例14: runtests
def runtests(test_names, test_dir='.', collect_only=False,
report_format='console', browser_type='Firefox',
javascript_disabled=False,
shared_directory=None, screenshots_on=False, failfast=False,
debug=False, webdriver_remote_url=None, device='', version='',
browser_platform='ANY', session_name=None,
browserstack_enabled=False, vagrant_enabled=False,
saucelabs_enabled=False, custom_options=None,
extended=False, skip_tracking=False):
if test_dir == 'selftests':
# XXXX horrible hardcoding
# selftests should be a command instead
package_dir = os.path.dirname(__file__)
test_dir = os.path.join(package_dir, 'selftests')
test_dir = _get_full_path(test_dir)
if not os.path.isdir(test_dir):
msg = 'Specified directory %r does not exist' % test_dir
print msg
sys.exit(1)
shared_directory = find_shared_directory(test_dir, shared_directory)
config.shared_directory = shared_directory
sys.path.append(shared_directory)
config.results_directory = _get_full_path('results')
config.saucelabs_enabled = saucelabs_enabled
config.browserstack_enabled = browserstack_enabled
config.vagrant_enabled = vagrant_enabled
test_names = set(test_names)
suites = get_suites(test_names, test_dir, shared_directory, collect_only,
browser_type, device, version, browser_platform,
session_name, javascript_disabled, webdriver_remote_url,
screenshots_on, failfast, debug, saucelabs_enabled=saucelabs_enabled,
browserstack_enabled=browserstack_enabled, vagrant_enabled=vagrant_enabled,
skip_tracking=skip_tracking, custom_options=custom_options, extended=extended
)
alltests = TestSuite(suites)
if not alltests.countTestCases():
print 'Error: Did not find any tests'
sys.exit(1)
if collect_only:
print 'Collect-Only Enabled, Not Running Tests...\n'
print 'Tests Collected:'
print '-' * 16
for t in sorted(testtools.testsuite.iterate_tests(alltests)):
print t.id()
sys.exit(0)
if report_format == 'xml':
_make_results_dir()
fp = file(os.path.join(config.results_directory, 'results.xml'), 'wb')
# XXX failfast not supported in XMLTestRunner
runner = junitxmlrunner.XMLTestRunner(output=fp, verbosity=2)
elif report_format == 'html':
_make_results_dir()
fp = file(os.path.join(config.results_directory, 'results.html'), 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp, title='SST Test Report', verbosity=2, failfast=failfast
)
else:
if config.email_notification_enabled:
stream = cStringIO.StringIO()
else:
stream = sys.stderr
runner = TextTestRunner(verbosity=2, failfast=failfast, stream=stream,
resultclass=SSTTextTestResult)
try:
return runner.run(alltests)
except KeyboardInterrupt:
print >> sys.stderr, 'Test run interrupted'
finally:
# XXX should warn on cases that were specified but not found
pass
示例15: load_tests
def load_tests(loader, standard_tests, pattern):
"""Returns the test suite for this module."""
suite = TestSuite()
suite.addTest(loader.loadTestsFromTestCase(HelpersTest))
suite.addTest(loader.loadTestsFromTestCase(ModelHelpersTest))
return suite