当前位置: 首页>>代码示例>>Python>>正文


Python Step.match方法代码示例

本文整理汇总了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
开发者ID:morepath,项目名称:morepath,代码行数:31,代码来源:test_traject.py

示例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
开发者ID:morepath,项目名称:morepath,代码行数:13,代码来源:test_traject.py

示例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'
开发者ID:kod3r,项目名称:morepath,代码行数:16,代码来源:test_traject.py

示例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"
开发者ID:reinout,项目名称:morepath,代码行数:16,代码来源:test_traject.py

示例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 == {}
开发者ID:morepath,项目名称:morepath,代码行数:17,代码来源:test_traject.py

示例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() == '{}'
开发者ID:blaflamme,项目名称:morepath,代码行数:12,代码来源:test_traject.py

示例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() == "{}"
开发者ID:reinout,项目名称:morepath,代码行数:12,代码来源:test_traject.py

示例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"
开发者ID:reinout,项目名称:morepath,代码行数:13,代码来源:test_traject.py

示例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() == '{}'
开发者ID:blaflamme,项目名称:morepath,代码行数:7,代码来源:test_traject.py

示例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}'
开发者ID:kod3r,项目名称:morepath,代码行数:7,代码来源:test_traject.py


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