• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testtools.RunTest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testtools.RunTest的典型用法代码示例。如果您正苦于以下问题:Python RunTest类的具体用法?Python RunTest怎么用?Python RunTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RunTest类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test__run_core_called

 def test__run_core_called(self):
     case = self.make_case()
     log = []
     run = RunTest(case, lambda x: x)
     run._run_core = lambda: log.append('foo')
     run.run()
     self.assertEqual(['foo'], log)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:7,代码来源:test_runtest.py


示例2: test__run_user_does_not_catch_keyboard

 def test__run_user_does_not_catch_keyboard(self):
     case = self.make_case()
     def raises():
         raise KeyboardInterrupt("yo")
     run = RunTest(case, None)
     run.result = ExtendedTestResult()
     self.assertRaises(KeyboardInterrupt, run._run_user, raises)
     self.assertEqual([], run.result._events)
开发者ID:endisd,项目名称:samba,代码行数:8,代码来源:test_runtest.py


示例3: test__run_user_returns_result

 def test__run_user_returns_result(self):
     case = self.make_case()
     def returns():
         return 1
     run = RunTest(case)
     run.result = ExtendedTestResult()
     self.assertEqual(1, run._run_user(returns))
     self.assertEqual([], run.result._events)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:8,代码来源:test_runtest.py


示例4: test__run_user_does_not_catch_keyboard

 def test__run_user_does_not_catch_keyboard(self):
     case = self.make_case()
     def raises():
         raise KeyboardInterrupt("yo")
     run = RunTest(case, None)
     run.result = ExtendedTestResult()
     self.assertThat(lambda: run._run_user(raises),
         Raises(MatchesException(KeyboardInterrupt)))
     self.assertEqual([], run.result._events)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:9,代码来源:test_runtest.py


示例5: test__run_prepared_result_calls_start_and_stop_test

 def test__run_prepared_result_calls_start_and_stop_test(self):
     result = ExtendedTestResult()
     case = self.make_case()
     run = RunTest(case, lambda x: x)
     run.run(result)
     self.assertEqual([
         ('startTest', case),
         ('addSuccess', case),
         ('stopTest', case),
         ], result._events)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:10,代码来源:test_runtest.py


示例6: test__run_user_can_catch_Exception

 def test__run_user_can_catch_Exception(self):
     case = self.make_case()
     e = Exception('Yo')
     def raises():
         raise e
     log = []
     run = RunTest(case, [(Exception, None)])
     run.result = ExtendedTestResult()
     status = run._run_user(raises)
     self.assertEqual(run.exception_caught, status)
     self.assertEqual([], run.result._events)
     self.assertEqual([], log)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:12,代码来源:test_runtest.py


示例7: test_run_with_result

 def test_run_with_result(self):
     # test.run passes result down to _run_test_method.
     log = []
     class Case(TestCase):
         def _run_test_method(self, result):
             log.append(result)
     case = Case('_run_test_method')
     run = RunTest(case, lambda x: log.append(x))
     result = TestResult()
     run.run(result)
     self.assertEqual(1, len(log))
     self.assertEqual(result, log[0].decorated)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:12,代码来源:test_runtest.py


示例8: test__run_prepared_result_calls_stop_test_always

 def test__run_prepared_result_calls_stop_test_always(self):
     result = ExtendedTestResult()
     case = self.make_case()
     def inner():
         raise Exception("foo")
     run = RunTest(case, lambda x: x)
     run._run_core = inner
     self.assertRaises(Exception, run.run, result)
     self.assertEqual([
         ('startTest', case),
         ('stopTest', case),
         ], result._events)
开发者ID:endisd,项目名称:samba,代码行数:12,代码来源:test_runtest.py


示例9: test__run_user_uncaught_Exception_raised

 def test__run_user_uncaught_Exception_raised(self):
     case = self.make_case()
     e = KeyError('Yo')
     def raises():
         raise e
     log = []
     def log_exc(self, result, err):
         log.append((result, err))
     run = RunTest(case, [(ValueError, log_exc)])
     run.result = ExtendedTestResult()
     self.assertRaises(KeyError, run._run_user, raises)
     self.assertEqual([], run.result._events)
     self.assertEqual([], log)
开发者ID:endisd,项目名称:samba,代码行数:13,代码来源:test_runtest.py


示例10: test__run_prepared_result_does_not_mask_keyboard

 def test__run_prepared_result_does_not_mask_keyboard(self):
     class Case(TestCase):
         def test(self):
             raise KeyboardInterrupt("go")
     case = Case('test')
     run = RunTest(case)
     run.result = ExtendedTestResult()
     self.assertThat(lambda: run._run_prepared_result(run.result),
         Raises(MatchesException(KeyboardInterrupt)))
     self.assertEqual(
         [('startTest', case), ('stopTest', case)], run.result._events)
     # tearDown is still run though!
     self.assertEqual(True, getattr(case, '_TestCase__teardown_called'))
开发者ID:ClusterHQ,项目名称:testtools,代码行数:13,代码来源:test_runtest.py


示例11: test__run_prepared_result_uncaught_Exception_raised

 def test__run_prepared_result_uncaught_Exception_raised(self):
     e = KeyError('Yo')
     class Case(TestCase):
         def test(self):
             raise e
     case = Case('test')
     log = []
     def log_exc(self, result, err):
         log.append((result, err))
     run = RunTest(case, [(ValueError, log_exc)])
     run.result = ExtendedTestResult()
     self.assertThat(lambda: run._run_prepared_result(run.result),
         Raises(MatchesException(KeyError)))
     self.assertEqual(
         [('startTest', case), ('stopTest', case)], run.result._events)
     self.assertEqual([], log)
开发者ID:allenap,项目名称:testtools,代码行数:16,代码来源:test_runtest.py


示例12: test__run_prepared_result_does_not_mask_keyboard

 def test__run_prepared_result_does_not_mask_keyboard(self):
     tearDownRuns = []
     class Case(TestCase):
         def test(self):
             raise KeyboardInterrupt("go")
         def _run_teardown(self, result):
             tearDownRuns.append(self)
             return super(Case, self)._run_teardown(result)
     case = Case('test')
     run = RunTest(case)
     run.result = ExtendedTestResult()
     self.assertThat(lambda: run._run_prepared_result(run.result),
         Raises(MatchesException(KeyboardInterrupt)))
     self.assertEqual(
         [('startTest', case), ('stopTest', case)], run.result._events)
     # tearDown is still run though!
     self.assertThat(tearDownRuns, HasLength(1))
开发者ID:allenap,项目名称:testtools,代码行数:17,代码来源:test_runtest.py


示例13: test__run_user_calls_onException

 def test__run_user_calls_onException(self):
     case = self.make_case()
     log = []
     def handler(exc_info):
         log.append("got it")
         self.assertEqual(3, len(exc_info))
         self.assertIsInstance(exc_info[1], KeyError)
         self.assertIs(KeyError, exc_info[0])
     case.addOnException(handler)
     e = KeyError('Yo')
     def raises():
         raise e
     run = RunTest(case, [(KeyError, None)])
     run.result = ExtendedTestResult()
     status = run._run_user(raises)
     self.assertEqual(run.exception_caught, status)
     self.assertEqual([], run.result._events)
     self.assertEqual(["got it"], log)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:18,代码来源:test_runtest.py


示例14: test__run_user_uncaught_Exception_from_exception_handler_raised

 def test__run_user_uncaught_Exception_from_exception_handler_raised(self):
     case = self.make_case()
     def broken_handler(exc_info):
         # ValueError because thats what we know how to catch - and must
         # not.
         raise ValueError('boo')
     case.addOnException(broken_handler)
     e = KeyError('Yo')
     def raises():
         raise e
     log = []
     def log_exc(self, result, err):
         log.append((result, err))
     run = RunTest(case, [(ValueError, log_exc)])
     run.result = ExtendedTestResult()
     self.assertRaises(ValueError, run._run_user, raises)
     self.assertEqual([], run.result._events)
     self.assertEqual([], log)
开发者ID:endisd,项目名称:samba,代码行数:18,代码来源:test_runtest.py


示例15: test__run_prepared_result_uncaught_Exception_triggers_error

 def test__run_prepared_result_uncaught_Exception_triggers_error(self):
     # https://bugs.launchpad.net/testtools/+bug/1364188
     # When something isn't handled, the test that was
     # executing has errored, one way or another.
     e = SystemExit(0)
     class Case(TestCase):
         def test(self):
             raise e
     case = Case('test')
     log = []
     def log_exc(self, result, err):
         log.append((result, err))
     run = RunTest(case, [], log_exc)
     run.result = ExtendedTestResult()
     self.assertThat(lambda: run._run_prepared_result(run.result),
         Raises(MatchesException(SystemExit)))
     self.assertEqual(
         [('startTest', case), ('stopTest', case)], run.result._events)
     self.assertEqual([(run.result, e)], log)
开发者ID:allenap,项目名称:testtools,代码行数:19,代码来源:test_runtest.py


示例16: test_run_no_result_manages_new_result

 def test_run_no_result_manages_new_result(self):
     log = []
     run = RunTest(self.make_case(), lambda x: log.append(x) or x)
     result = run.run()
     self.assertIsInstance(result.decorated, TestResult)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:5,代码来源:test_runtest.py



注:本文中的testtools.RunTest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testtools.TestCase类代码示例发布时间:2022-05-27
下一篇:
Python testtools.iterate_tests函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap