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

Python expects.raise_error函数代码示例

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

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



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


示例16: test_should_fail_if_not_really_money

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


示例17: test_should_fail_if_check_request_is_missing

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


示例18: test_should_fail_if_service_name_does_not_match

 def test_should_fail_if_service_name_does_not_match(self):
     req = _make_test_request(self.SERVICE_NAME + u'-will-not-match')
     testf = lambda: self.agg.report(req)
     expect(testf).to(raise_error(ValueError))
开发者ID:danacton,项目名称:appengine-endpoints-modules-lnkr,代码行数:4,代码来源:test_report_request.py


示例19: description

from expects import expect, equal, raise_error
from bankbarcode.cuaderno57 import Recibo507

with description('Recibo507 with due date of cuaderno57'):
    with it('Validate than suffix is less than 500'):
        def callback():
            entity = '01234567'
            suffix = '023'
            ref = '12345678901'
            notice = '123456'
            amount = '6543.21'
            due_date = datetime(2015, 11, 01)
            recibo = Recibo507(entity, suffix, ref, notice, amount, due_date)
        expect(callback).to(
            raise_error(ValueError,
                        'suffix with due date must be bigger than 499'))

    with it('Overwrites introduced notice for due date DDMMAA'):
        entity = '22350466'
        suffix = '501'
        ref = '00000000015'
        notice = '300815'
        amount = '53.98'
        due_date = datetime(2015, 11, 01)
        recibo = Recibo507(entity, suffix, ref, notice, amount, due_date)
        expect(recibo.notice).not_to(equal(notice))
        expect(recibo.notice).to(equal(due_date.strftime('%d%m%y')))

    with it('accomplish the example of cuaderno57 with due date Datetime'):
        entity = '22350466'
        suffix = '501'
开发者ID:kailIII,项目名称:bankbarcode,代码行数:31,代码来源:cuaderno57_Recibo507_due_date_spec.py


示例20: test_should_fail_on_dissimilar_bucket_counts

 def test_should_fail_on_dissimilar_bucket_counts(self):
     for _, d2, d3 in self.merge_triples:
         testf = lambda: distribution.merge(d2, d3)
         expect(testf).to(raise_error(ValueError))
开发者ID:catapult-project,项目名称:catapult,代码行数:4,代码来源:test_distribution.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python testing.failure函数代码示例发布时间:2022-05-24
下一篇:
Python expects.expect函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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