当前位置: 首页>>代码示例>>Python>>正文


Python RunTest._run_user方法代码示例

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


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

示例1: test__run_user_returns_result

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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,代码行数:10,代码来源:test_runtest.py

示例2: test__run_user_does_not_catch_keyboard

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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,代码行数:11,代码来源:test_runtest.py

示例3: test__run_user_can_catch_Exception

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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,代码行数:14,代码来源:test_runtest.py

示例4: test__run_user_uncaught_Exception_raised

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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.assertThat(lambda: run._run_user(raises),
         Raises(MatchesException(KeyError)))
     self.assertEqual([], run.result._events)
     self.assertEqual([], log)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:16,代码来源:test_runtest.py

示例5: test__run_user_calls_onException

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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,代码行数:20,代码来源:test_runtest.py

示例6: test__run_user_uncaught_Exception_from_exception_handler_raised

# 需要导入模块: from testtools import RunTest [as 别名]
# 或者: from testtools.RunTest import _run_user [as 别名]
 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.assertThat(lambda: run._run_user(raises),
         Raises(MatchesException(ValueError)))
     self.assertEqual([], run.result._events)
     self.assertEqual([], log)
开发者ID:IsCoolEntertainment,项目名称:debpkg_percona-xtrabackup,代码行数:21,代码来源:test_runtest.py


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