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


Python expects.raise_error函数代码示例

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


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

示例1: test_should_fail_if_inputs_do_not_have_the_same_type

 def test_should_fail_if_inputs_do_not_have_the_same_type(self):
     testf = lambda: timestamp.compare(self.TESTS[0][0],
                                       datetime.datetime.utcnow())
     expect(testf).to(raise_error(ValueError))
     testf = lambda: timestamp.compare(self.TESTS[0],
                                       datetime.datetime.utcnow())
     expect(testf).to(raise_error(ValueError))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:7,代码来源:test_timestamp.py

示例2: test_should_fail_if_service_is_bad

 def test_should_fail_if_service_is_bad(self):
     testfs = [
         lambda: self._get_registry(),
         lambda: service.MethodRegistry(None),
         lambda: service.MethodRegistry(object()),
     ]
     for f in testfs:
         expect(f).to(raise_error(ValueError))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:8,代码来源:test_service.py

示例3: test_should_fail_if_non_money_is_used

 def test_should_fail_if_non_money_is_used(self):
     testfs = [
         lambda: money.add(self._SOME_YEN, object()),
         lambda: money.add(object(), self._SOME_USD),
         lambda: money.add(None, self._SOME_USD),
         lambda: money.add(self._SOME_YEN, None),
     ]
     for testf in testfs:
         expect(testf).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:9,代码来源:test_money.py

示例4: test_should_fail_for_delta_metrics_with_unmergable_types

 def test_should_fail_for_delta_metrics_with_unmergable_types(self):
     no_init = metric_value.create()
     unmergeables = [
         metric_value.create(stringValue='a test string'),
         metric_value.create(boolValue=False),
     ]
     for mv in unmergeables:
         testf = lambda: metric_value.merge(MetricKind.DELTA, mv, mv)
         expect(testf).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:9,代码来源:test_metric_value.py

示例5: test_should_fail_on_dissimilar_bucket_options

 def test_should_fail_on_dissimilar_bucket_options(self):
     explicit = _make_explicit_dist()
     linear = _make_linear_dist()
     exponential = _make_exponential_dist()
     pairs = (
         (explicit, linear),
         (explicit, exponential),
         (linear, exponential)
     )
     for p in pairs:
         testf = lambda: distribution.merge(*p)
         expect(testf).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:12,代码来源:test_distribution.py

示例6: test_should_fail_if_bad_options_are_used

 def test_should_fail_if_bad_options_are_used(self):
     should_fail = [
         lambda: caches.create(object()),
     ]
     for testf in should_fail:
         expect(testf).to(raise_error(ValueError))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:6,代码来源:test_caches.py

示例7: test_constructor_should_fail_on_bad_deques

 def test_constructor_should_fail_on_bad_deques(self):
     testf = lambda: caches.DequeOutTTLCache(_TEST_NUM_ENTRIES, _TEST_TTL,
                                             out_deque=object())
     expect(testf).to(raise_error(ValueError))
开发者ID:AndreaBuffa,项目名称:trenordsaga,代码行数:4,代码来源:test_caches.py

示例8: test_should_fail_on_unallowed_negative_overflows

 def test_should_fail_on_unallowed_negative_overflows(self):
     testf = lambda: money.add(self._SOME_YEN_DEBT, self._LARGE_YEN_DEBT)
     expect(testf).to(raise_error(OverflowError))
开发者ID:catapult-project,项目名称:catapult,代码行数:3,代码来源:test_money.py

示例9: description

from expects import expect, raise_error
from bankbarcode.bankbarcode import BankBarcode

with description('BankBarcode'):
    with it('doesn\'t have code generation method'):
        error = 'This method is not implemented!'

        def callback():
            return BankBarcode().code()

        expect(callback).to(raise_error(NotImplementedError, error))

    with it('can\'t create barcode without code generation method'):
        path = '/tmp/mybarcode'
        error = 'This method is not implemented!'

        def callback():
            return BankBarcode().save(path)

        expect(callback).to(raise_error(NotImplementedError, error))

    with it('can\'t create SVG without code generation method'):
        error = 'This method is not implemented!'

        def callback():
            return BankBarcode().svg()

        expect(callback).to(raise_error(NotImplementedError, error))
开发者ID:kailIII,项目名称:bankbarcode,代码行数:28,代码来源:BankBarcode_spec.py

示例10: test_should_fail_if_req_is_bad

 def test_should_fail_if_req_is_bad(self):
     testf = lambda: self.agg.report(object())
     expect(testf).to(raise_error(ValueError))
     testf = lambda: self.agg.report(None)
     expect(testf).to(raise_error(ValueError))
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:5,代码来源:test_report_request.py

示例11: test_should_raise_if_constructed_with_a_bad_error_cause

 def test_should_raise_if_constructed_with_a_bad_error_cause(self):
     testf = lambda: report_request.Info(error_cause=object())
     expect(testf).to(raise_error(ValueError))
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:3,代码来源:test_report_request.py

示例12: test_should_fail_when_the_units_and_nanos_are_mismatched

 def test_should_fail_when_the_units_and_nanos_are_mismatched(self):
     for m in self._MISMATCHED_UNITS:
         expect(lambda: money.check_valid(m)).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:3,代码来源:test_money.py

示例13: test_should_fail_if_no_buckets_are_set

 def test_should_fail_if_no_buckets_are_set(self):
     testf = lambda: distribution.add_sample(_UNDERFLOW_SAMPLE,
                                             self.NOTHING_SET)
     expect(testf).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:4,代码来源:test_distribution.py

示例14: test_should_fail_when_no_currency_is_set

 def test_should_fail_when_no_currency_is_set(self):
     expect(lambda: money.check_valid(messages.Money())).to(
         raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:3,代码来源:test_money.py

示例15: test_should_fail_when_the_currency_is_bad

 def test_should_fail_when_the_currency_is_bad(self):
     expect(lambda: money.check_valid(self._BAD_CURRENCY)).to(
         raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:3,代码来源:test_money.py


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