本文整理汇总了Python中utils.assert_raises函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises函数的具体用法?Python assert_raises怎么用?Python assert_raises使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_raises函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_file_handler_construction_fails_with_more_than_two_parameters
def test_file_handler_construction_fails_with_more_than_two_parameters(self):
assert_raises(TypeError,
models.FileHandler,
None,
None,
None,
exc_pattern=r'__init__.. takes at most 3 arguments .4 given.')
开发者ID:gabrielfalcao,项目名称:ma-cherie,代码行数:7,代码来源:test_file_handler.py
示例2: test_set_as_lazy_fail_when_not_not_bool
def test_set_as_lazy_fail_when_not_not_bool(self):
rl = models.RelationShip()
assert_raises(TypeError, rl.set_lazy, None)
assert_raises(TypeError, rl.set_lazy, object())
assert_raises(TypeError, rl.set_lazy, {})
assert_raises(TypeError, rl.set_lazy, [])
assert_raises(TypeError, rl.set_lazy, ())
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:7,代码来源:test_relationship_base.py
示例3: test_render_html_param_filename_takes_string
def test_render_html_param_filename_takes_string():
assert_raises(TypeError, template.render_html, None, None,
exc_pattern=r'sponge.template.render_html ' \
'takes a string as filename param, got None.')
assert_raises(TypeError, template.render_html, 5, None,
exc_pattern=r'sponge.template.render_html ' \
'takes a string as filename param, got 5.')
开发者ID:gabrielfalcao,项目名称:sponge,代码行数:7,代码来源:test_template.py
示例4: test_set_as_self_referenced_fail_when_not_not_bool
def test_set_as_self_referenced_fail_when_not_not_bool(self):
rl = models.RelationShip()
assert_raises(TypeError, rl.set_self_referenced, None)
assert_raises(TypeError, rl.set_self_referenced, object())
assert_raises(TypeError, rl.set_self_referenced, {})
assert_raises(TypeError, rl.set_self_referenced, [])
assert_raises(TypeError, rl.set_self_referenced, ())
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:7,代码来源:test_relationship_base.py
示例5: test_templates_render_html_raises_context_already_have_make_url
def test_templates_render_html_raises_context_already_have_make_url():
assert_raises(KeyError,
template.render_html,
'index.html',
{'make_url': "ss"},
exc_pattern=r'The key "make_url" is already in ' \
'template context as[:] %s' % re.escape(repr(template.make_url)))
开发者ID:gabrielfalcao,项目名称:sponge,代码行数:7,代码来源:test_template.py
示例6: test_templates_render_html_raises_filename_empty
def test_templates_render_html_raises_filename_empty():
assert_raises(TypeError,
template.render_html,
'',
{},
exc_pattern=r'sponge.template.render_html ' \
'filename param can not be empty.')
开发者ID:gabrielfalcao,项目名称:sponge,代码行数:7,代码来源:test_template.py
示例7: test_action_registry_raises_if_action_does_not_feature_regex
def test_action_registry_raises_if_action_does_not_feature_regex():
def should_raise():
class ActionToTest5(ActionBase):
def execute():
pass
assert_raises(NotImplementedError, should_raise, exc_pattern=r'^The action ActionToTest5 does not implement the attribute regex$')
开发者ID:heynemann,项目名称:crane,代码行数:7,代码来源:test_action_registry.py
示例8: test_setup_all_path_must_be_absolute
def test_setup_all_path_must_be_absolute():
d = {}
cf = core.ConfigValidator({})
sp = core.SpongeConfig(d, cf)
assert_raises(TypeError, sp.setup_all, 'relative/path/',
exc_pattern=r'SpongeConfig.setup_all takes a ' \
'absolute path, got relative/path/.')
开发者ID:gabrielfalcao,项目名称:sponge,代码行数:7,代码来源:test_sponge_config.py
示例9: test_model_file_manager_get_raises_wrong_param
def test_model_file_manager_get_raises_wrong_param():
class Woo(Model):
objects = managers.FileSystemModelManager(base_path='/home/woo')
def __unicode__(self):
return '<FooBar(name=%r)>' % self.name
assert_raises(TypeError, Woo.objects.get, blabla='x', exc_pattern=r'blabla is not a valid field in %r' % Woo)
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:7,代码来源:test_file_manager.py
示例10: test_model_file_manager_method_delete_takes_model_or_modelset
def test_model_file_manager_method_delete_takes_model_or_modelset():
codecs_mock = Mock()
file_mock = Mock()
path_mock = Mock()
path_mock.expects(once()).exists(eq('/home/wee/Wee.json')).will(return_value(True))
path_mock.expects(once()).exists(eq('/home/wee')).will(return_value(True))
os_path_module = managers.os.path
codecs_module = managers.codecs
managers.codecs = codecs_mock
managers.os.path = path_mock
class Wee(Model):
objects = managers.FileSystemModelManager(base_path='/home/wee')
assert_raises(TypeError, Wee.objects.delete, None,
exc_pattern=r'delete\(\) takes a Wee as parameter, got None')
assert_raises(TypeError, Wee.objects.delete, 5,
exc_pattern=r'delete\(\) takes a Wee as parameter, got 5')
file_mock.verify()
codecs_mock.verify()
managers.codecs = codecs_module
managers.os.path = os_path_module
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:27,代码来源:test_file_manager.py
示例11: test_page_registry_resolve_raises_with_wrong_none_url
def test_page_registry_resolve_raises_with_wrong_none_url():
def do_resolve_fail():
PageRegistry.resolve(Settings(), None, exists_func=fake_abs)
exc = 'PageRegistry.resolve argument 2 must be a string. Got None.'
assert_raises(TypeError, do_resolve_fail,
exc_pattern=re_compile(exc))
开发者ID:GunioRobot,项目名称:pyccuracy,代码行数:7,代码来源:test_page_registry.py
示例12: test_floatfield_fail_on_validate
def test_floatfield_fail_on_validate(self):
class Person(Model):
weight = fields.FloatField()
person_dict = {'Person': {'weight': None}}
assert_raises(fields.FieldValidationError,
Person.from_dict,
person_dict)
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:8,代码来源:test_fields.py
示例13: test_request_fails_with_headers_non_dict
def test_request_fails_with_headers_non_dict():
b = Bolacha()
assert_raises(TypeError, b.request, 'http://somewhere', 'GET', headers=5,
exc_pattern=r'Bolacha.request, parameter headers must be ' \
'a dict or NoneType. Got 5')
assert_raises(TypeError, b.request, 'http://somewhere', 'GET', headers='bla',
exc_pattern=r'Bolacha.request, parameter headers must be ' \
'a dict or NoneType. Got \'bla\'')
开发者ID:aficionado,项目名称:bolacha,代码行数:8,代码来源:test_bolacha.py
示例14: test_time
def test_time():
dta1 = TimeAttribute("%H:%M:%S")
dta2 = TimeAttribute("%H:%M:%S")
dta1.fill('creation_time', '23:44:10')
dta2.fill('creation_time', time(hour=23, minute=44, second=10))
assert_equals(dta1.value, time(hour=23, minute=44, second=10))
assert_equals(dta2.value, time(hour=23, minute=44, second=10))
assert_raises(TypeError, dta1.fill, 'creation_time', 100.5)
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:8,代码来源:test_attributes.py
示例15: test_textfield_fail
def test_textfield_fail(self):
class Person(Model):
biography = fields.TextField()
person_dict = {'Person': {'biography': 00}}
assert_raises(TypeError,
Person.from_dict,
person_dict)
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:8,代码来源:test_fields.py
示例16: test_booleanfield_fail
def test_booleanfield_fail(self):
class Person(Model):
married = fields.BooleanField(positives=["true", "yes"],
negatives=["false", "no"])
person_dict = {'Person': {'married': None}}
assert_raises(TypeError, Person.from_dict, person_dict)
开发者ID:andrewsmedina,项目名称:dead-parrot,代码行数:8,代码来源:test_fields.py
示例17: test_page_registry_resolve_raises_with_wrong_none_settings_and_none_url
def test_page_registry_resolve_raises_with_wrong_none_settings_and_none_url():
def do_resolve_fail():
PageRegistry.resolve(None, None, exists_func=fake_abs)
exc = 'PageRegistry.resolve takes a pyccuracy.common.Settings ' \
'object first parameter. Got None.'
assert_raises(TypeError, do_resolve_fail,
exc_pattern=re_compile(exc))
开发者ID:GunioRobot,项目名称:pyccuracy,代码行数:8,代码来源:test_page_registry.py
示例18: test_request_fails_method_non_string
def test_request_fails_method_non_string():
b = Bolacha()
assert_raises(TypeError, b.request, 'http://gnu', None,
exc_pattern=r'Bolacha.request, parameter method must be ' \
'a string. Got None')
assert_raises(TypeError, b.request, 'http://gnu', 99,
exc_pattern=r'Bolacha.request, parameter method must be ' \
'a string. Got 99')
开发者ID:aficionado,项目名称:bolacha,代码行数:8,代码来源:test_bolacha.py
示例19: test_takes_dict_on_creation
def test_takes_dict_on_creation():
cf = core.ConfigValidator({})
assert_raises(TypeError, core.SpongeConfig, None, cf,
exc_pattern=r'SpongeConfig parameter 1 ' \
'must be a dict, got None.')
assert_raises(TypeError, core.SpongeConfig, 5, cf,
exc_pattern=r'SpongeConfig parameter 1 ' \
'must be a dict, got 5.')
开发者ID:gabrielfalcao,项目名称:sponge,代码行数:8,代码来源:test_sponge_config.py
示例20: test_request_fails_url_non_string
def test_request_fails_url_non_string():
b = Bolacha()
assert_raises(TypeError, b.request, None, None,
exc_pattern=r'Bolacha.request, parameter url must be ' \
'a string. Got None')
assert_raises(TypeError, b.request, 99, None,
exc_pattern=r'Bolacha.request, parameter url must be ' \
'a string. Got 99')
开发者ID:aficionado,项目名称:bolacha,代码行数:8,代码来源:test_bolacha.py
注:本文中的utils.assert_raises函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论