本文整理汇总了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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))
示例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))