本文整理汇总了Python中util.assert_invalid函数的典型用法代码示例。如果您正苦于以下问题:Python assert_invalid函数的具体用法?Python assert_invalid怎么用?Python assert_invalid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_invalid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_equal
def test_equal():
v = V.equal('egg', msg="not equal")
assert v.__name__ == "equal"
assert v('egg') == 'egg'
assert_invalid(
lambda: v('bob'),
{None: 'not equal'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_base.py
示例2: test_parse_time
def test_parse_time():
fmt='%m %d %Y'
msg="potted shrimp"
v=V.parse_time(fmt, msg)
ts=v('10 03 2007')[:3]
assert ts==(2007, 10, 3)
assert_invalid(lambda: v('tough nuggie'), msg)
开发者ID:smulloni,项目名称:validino,代码行数:7,代码来源:test_base.py
示例3: test_confirm_type
def test_confirm_type():
v = V.confirm_type((int, float), 'not a number')
assert v.__name__ == "confirm_type"
assert v(45) == 45
assert_invalid(
lambda: v('45'),
{None: 'not a number'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_base.py
示例4: test_ip
def test_ip():
v = V.ip('donkey')
i = '192.168.1.243'
assert v(i) == i
assert_invalid(
lambda: v("this is not an ip"),
{None: 'donkey'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_extra.py
示例5: test_translate
def test_translate():
v = V.translate(dict(y=True, f=False), 'dong')
assert v.__name__ == "translate"
assert v('y') == True
assert_invalid(
lambda: v('pod'),
{None: 'dong'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_base.py
示例6: test_regex
def test_regex():
v = V.regex('shrubbery\d{3}$', 'regex')
assert v.__name__ == "regex"
assert v('shrubbery222') == 'shrubbery222'
assert_invalid(
lambda: v('buy a shrubbery333, ok?'),
{None: 'regex'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_base.py
示例7: test_not_equal
def test_not_equal():
v = V.not_equal('egg', msg='equal')
assert v.__name__ == "not_equal"
assert v('plop') == 'plop'
assert_invalid(
lambda: v('egg'),
{None: 'equal'})
开发者ID:bwhmather,项目名称:validino,代码行数:7,代码来源:test_base.py
示例8: test_is_list
def test_is_list():
msg = "list"
v = V.is_list(msg=msg)
assert v.__name__ == "is_list"
assert v([40]) == [40]
assert_invalid(
lambda: v(40),
{None: msg})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例9: test_is_scalar
def test_is_scalar():
msg = 'sc'
v = V.is_scalar(msg=msg)
assert v.__name__ == "is_scalar"
assert v(40) == 40
assert_invalid(
lambda: v([40]),
{None: msg})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例10: test_email
def test_email():
v=V.email()
e="[email protected]"
assert v(e)==e
e='[email protected]'
v=V.email(True, 'snog')
assert v(e)==e
assert_invalid(lambda: v('[email protected]'), 'snog')
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_extra.py
示例11: test_credit_card_1
def test_credit_card_1():
cc='4000000000998'
v=V.credit_card(msg="aha")
assert v(cc)==cc
assert_invalid(lambda: v('pain chocolat'), dict(cc_number=['aha']))
assert_invalid(lambda: v(str(int(cc)-1)), dict(cc_number=['aha']))
v=V.credit_card(require_type=True, msg='aha')
assert v((cc, 'Visa'))==(cc, 'Visa')
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_extra.py
示例12: test_clamp_length
def test_clamp_length():
msg='You are a pear'
v=V.clamp_length(min=3, msg=msg)
assert v('500')=='500'
assert_invalid(lambda: v('eh'), msg)
v=V.clamp_length(max=10, msg=dict(minlen='haha', maxlen='kong'))
assert v('40')=='40'
assert_invalid(lambda: v('I told you that Ronald would eat it when you were in the bathroom'), 'kong')
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_base.py
示例13: test_msg
def test_msg():
messages=dict(
integer="hey, I said use a number")
with msg(messages):
assert messages == getMessages()
assert_invalid(lambda: V.integer()('lump'), messages['integer'])
assert getMessages() != messages
assert_invalid(lambda: V.integer()('lump'), "not an integer")
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_messages.py
示例14: test_not_belongs
def test_not_belongs():
msg = "belittle my humbug"
v = V.not_belongs(range(5), msg=msg)
assert v.__name__ == "not_belongs"
assert v('pinko') == 'pinko'
assert_invalid(
lambda: v(4),
{None: msg})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例15: test_to_integer
def test_to_integer():
msg = "please enter an integer"
v = V.to_integer(msg=msg)
assert v.__name__ == "to_integer"
assert v('40') == 40
assert_invalid(
lambda: v('whack him until he screams'),
{None: msg})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例16: test_belongs
def test_belongs():
msg = "rinse me a robot"
v = V.belongs('pinko widget frog lump'.split(), msg=msg)
assert v.__name__ == "belongs"
assert v('pinko') == 'pinko'
assert_invalid(
lambda: v('snot'),
{None: msg})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例17: test_excursion
def test_excursion():
x='[email protected]'
v=V.excursion(lambda x: x.split('@')[0],
V.belongs(['gadzooks', 'willy'],
msg='pancreatic'))
assert x==v(x)
assert_invalid(lambda: v('hieratic impulses'), 'pancreatic')
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_base.py
示例18: test_fields_match
def test_fields_match():
d=dict(foo=3,
goo=3,
poo=56)
v=V.fields_match('foo', 'goo')
assert d==v(d)
v=V.fields_match('foo', 'poo', 'oink')
assert_invalid(lambda: v(d), 'oink')
开发者ID:smulloni,项目名称:validino,代码行数:8,代码来源:test_base.py
示例19: test_empty
def test_empty():
v = V.empty(msg="scorch me")
assert v.__name__ == "empty"
assert v('') == ''
assert v(None) == None
assert_invalid(
lambda: v("bob"),
{None: 'scorch me'})
开发者ID:bwhmather,项目名称:validino,代码行数:8,代码来源:test_base.py
示例20: test_clamp
def test_clamp():
msg='You are a pear'
v=V.clamp(min=30, msg=msg)
assert v(50)==50
assert_invalid(lambda: v(20), msg)
v=V.clamp(max=100, msg=dict(min='haha', max='kong'))
assert v(40)==40
assert_invalid(lambda: v(120), 'kong')
开发者ID:smulloni,项目名称:validino,代码行数:9,代码来源:test_base.py
注:本文中的util.assert_invalid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论