本文整理汇总了Python中morepath.traject.Step.match方法的典型用法代码示例。如果您正苦于以下问题:Python Step.match方法的具体用法?Python Step.match怎么用?Python Step.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类morepath.traject.Step
的用法示例。
在下文中一共展示了Step.match方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mixed_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_mixed_step():
step = Step('a{foo}b')
assert step.s == 'a{foo}b'
assert step.generalized == 'a{}b'
assert step.parts == ('a', 'b')
assert step.names == ['foo']
assert step.converters == {}
assert step.has_variables()
assert step.discriminator_info() == 'a{}b'
variables = {}
assert step.match('abarb', variables)
assert variables == {'foo': 'bar'}
variables = {}
assert not step.match('ab', variables)
assert not variables
variables = {}
assert not step.match('xbary', variables)
assert not variables
variables = {}
assert not step.match('yabarbx', variables)
assert not variables
variables = {}
assert not step.match('afoo', variables)
assert not variables
示例2: test_converter
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_converter():
step = Step('{foo}', converters=dict(foo=Converter(int)))
assert step.discriminator_info() == '{}'
variables = {}
assert step.match('1', variables)
assert variables == {'foo': 1}
variables = {}
assert not step.match('x', variables)
assert not variables
示例3: test_mixed_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_mixed_step():
step = Step('a{foo}b')
assert step.s == 'a{foo}b'
assert step.generalized == 'a{}b'
assert step.parts == ('a', 'b')
assert step.names == ['foo']
assert step.converters == [str]
assert step.has_variables()
assert step.match('abarb') == (True, {'foo': 'bar'})
assert step.match('ab') == (False, {})
assert step.match('xbary') == (False, {})
assert step.match('yabarbx') == (False, {})
assert step.match('afoo') == (False, {})
assert step.discriminator_info() == 'a{str}b'
示例4: test_mixed_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_mixed_step():
step = Step("a{foo}b")
assert step.s == "a{foo}b"
assert step.generalized == "a{}b"
assert step.parts == ("a", "b")
assert step.names == ["foo"]
assert step.converters == {}
assert step.has_variables()
assert step.match("abarb") == (True, {"foo": "bar"})
assert step.match("ab") == (False, {})
assert step.match("xbary") == (False, {})
assert step.match("yabarbx") == (False, {})
assert step.match("afoo") == (False, {})
assert step.discriminator_info() == "a{}b"
示例5: test_name_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_name_step():
step = Step('foo')
assert step.s == 'foo'
assert step.generalized == 'foo'
assert step.parts == ('foo',)
assert step.names == []
assert step.converters == {}
assert step.discriminator_info() == 'foo'
assert not step.has_variables()
variables = {}
assert step.match('foo', variables)
assert variables == {}
assert not step.match('bar', variables)
assert variables == {}
示例6: test_variable_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_variable_step():
step = Step('{foo}')
assert step.s == '{foo}'
assert step.generalized == '{}'
assert step.parts == ('', '')
assert step.names == ['foo']
assert step.converters == {}
assert step.has_variables()
assert step.match('bar') == (True, {'foo': 'bar'})
assert step.discriminator_info() == '{}'
示例7: test_variable_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_variable_step():
step = Step("{foo}")
assert step.s == "{foo}"
assert step.generalized == "{}"
assert step.parts == ("", "")
assert step.names == ["foo"]
assert step.converters == {}
assert step.has_variables()
assert step.match("bar") == (True, {"foo": "bar"})
assert step.discriminator_info() == "{}"
示例8: test_name_step
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_name_step():
step = Step("foo")
assert step.s == "foo"
assert step.generalized == "foo"
assert step.parts == ("foo",)
assert step.names == []
assert step.converters == {}
assert not step.has_variables()
assert step.match("foo") == (True, {})
assert step.match("bar") == (False, {})
assert step.discriminator_info() == "foo"
示例9: test_converter
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_converter():
step = Step('{foo}', converters=dict(foo=Converter(int)))
assert step.match('1') == (True, {'foo': 1})
assert step.match('x') == (False, {})
assert step.discriminator_info() == '{}'
示例10: test_converter
# 需要导入模块: from morepath.traject import Step [as 别名]
# 或者: from morepath.traject.Step import match [as 别名]
def test_converter():
step = Step('{foo:int}')
assert step.match('1') == (True, {'foo': 1})
assert step.match('x') == (False, {})
assert step.discriminator_info() == '{int}'