本文整理汇总了Python中tests.unittest.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_copy_events_with_partials
# If we unregister the first event from the copied emitter,
# We should be able to register the second handler.
copied_emitter.unregister('foo', first_handler, 'bar')
copied_emitter.register('foo', second_handler, 'bar')
copied_emitter.emit('foo', id_name='third-time')
self.assertEqual(first, ['first-time', 'second-time'])
self.assertEqual(second, ['third-time'])
# The original event emitter should have the unique id event still
# registered though.
self.emitter.emit('foo', id_name='fourth-time')
self.assertEqual(first, ['first-time', 'second-time', 'fourth-time'])
self.assertEqual(second, ['third-time'])
def test_copy_events_with_partials(self):
# There's a bug in python2.6 where you can't deepcopy
# a partial object. We want to ensure that doesn't
# break when a partial is hooked up as an event handler.
def handler(a, b, **kwargs):
return b
f = functools.partial(handler, 1)
self.emitter.register('a.b', f)
copied = copy.copy(self.emitter)
self.assertEqual(copied.emit_until_response(
'a.b', b='return-val')[1], 'return-val')
if __name__ == '__main__':
unittest.main()
开发者ID:AdColony-Engineering,项目名称:botocore,代码行数:30,代码来源:test_hooks.py
示例2: test_write_config_with_specify_config_path
process.cleanup_mprocess(config_path, cfg)
def test_write_config_with_specify_config_path(self):
cfg = {'port': 27017, 'objcheck': 'true'}
fd_key, file_path = tempfile.mkstemp()
os.close(fd_key)
config_path = process.write_config(cfg, file_path)
self.assertEqual(file_path, config_path)
process.cleanup_mprocess(config_path, cfg)
def test_proc_alive(self):
p = subprocess.Popen([self.executable])
self.assertTrue(process.proc_alive(p))
p.terminate()
p.wait()
self.assertFalse(process.proc_alive(p))
self.assertFalse(process.proc_alive(None))
def test_read_config(self):
cfg = {"noprealloc": True, "smallfiles": False, "oplogSize": 10, "other": "some string"}
config_path = process.write_config(cfg)
self.tmp_files.append(config_path)
self.assertEqual(process.read_config(config_path), cfg)
if __name__ == '__main__':
unittest.main(verbosity=3)
# suite = unittest.TestSuite()
# suite.addTest(ProcessTestCase('test_repair'))
# unittest.TextTestRunner(verbosity=2).run(suite)
开发者ID:llvtt,项目名称:mongo-orchestration,代码行数:30,代码来源:test_process.py
示例3: construct_dummy_table
def construct_dummy_table(self, n_custom_fields=1):
fields = [Column('id')] + [
Column('v%d' % (i+1)) for i in range(n_custom_fields)
]
return Table('dummy_table')[fields]
def get_version(self, db):
rows = db("SELECT value FROM system WHERE name = %s",
(self.__class__.__name__,))
return int(rows[0][0]) if rows else 0
def update_version(self, db, version):
old_version = self.get_version(db)
if old_version:
db("UPDATE system SET value=%s WHERE name=%s",
(version, self.__class__.__name__,))
else:
db("INSERT INTO system (name, value) VALUES ('%s','%s')"
% (self.__class__.__name__, version))
return version
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(EnvironmentUpgradeTestCase, 'test'))
return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
开发者ID:thimalk,项目名称:bloodhound,代码行数:29,代码来源:upgrade.py
示例4: functionalSuite
suite.addTest(RegressionTestTicket6912b())
suite.addTest(RegressionTestTicket7821group())
suite.addTest(RegressionTestTicket7821var())
suite.addTest(RegressionTestTicket8247())
suite.addTest(RegressionTestTicket8861())
suite.addTest(RegressionTestTicket9084())
suite.addTest(RegressionTestTicket9981())
return suite
#--------------
# Multiproduct test cases
#--------------
def functionalSuite(suite=None):
if not suite:
from tests import functional
suite = functional.functionalSuite()
trac_functionalSuite(suite)
return suite
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='functionalSuite')
开发者ID:mohsadki,项目名称:dargest,代码行数:30,代码来源:ticket.py
注:本文中的tests.unittest.main函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论