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


Python UserData.getas方法代码示例

本文整理汇总了Python中behave.userdata.UserData.getas方法的典型用法代码示例。如果您正苦于以下问题:Python UserData.getas方法的具体用法?Python UserData.getas怎么用?Python UserData.getas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在behave.userdata.UserData的用法示例。


在下文中一共展示了UserData.getas方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_getas__with_known_param_and_preconverted_value

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
    def test_getas__with_known_param_and_preconverted_value(self):
        userdata = UserData(param=42)
        assert "param" in userdata, "ENSURE: known param"

        value = userdata.getas(int, "param")
        assert isinstance(value, int)
        self.assertEqual(value, 42)
开发者ID:007jasonsmith,项目名称:behave,代码行数:9,代码来源:test_userdata.py

示例2: test_getas__with_unknown_param_returns_default_value

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
    def test_getas__with_unknown_param_returns_default_value(self):
        userdata = UserData()
        assert "param" not in userdata, "ENSURE: unknown param"

        value = userdata.getas(int, "param", 123)
        assert isinstance(value, int)
        self.assertEqual(value, 123)
开发者ID:007jasonsmith,项目名称:behave,代码行数:9,代码来源:test_userdata.py

示例3: test_getas__with_known_param_and_valid_text

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
    def test_getas__with_known_param_and_valid_text(self):
        userdata = UserData(param="42")
        assert "param" in userdata, "ENSURE: known param"

        value = userdata.getas(int, "param")
        assert isinstance(value, int)
        assert value == 42
开发者ID:behave,项目名称:behave,代码行数:9,代码来源:test_userdata.py

示例4: test_getas__with_known_param_and_preconverted_value_and_valuetype

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
    def test_getas__with_known_param_and_preconverted_value_and_valuetype(self):
        userdata = UserData(param=42)
        assert "param" in userdata, "ENSURE: known param"

        def parse_int(text):
            return int(text)

        value = userdata.getas(parse_int, "param", valuetype=int)
        assert isinstance(value, int)
        self.assertEqual(value, 42)
开发者ID:007jasonsmith,项目名称:behave,代码行数:12,代码来源:test_userdata.py

示例5: test_getas__with_unknown_param_without_default_returns_none

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
    def test_getas__with_unknown_param_without_default_returns_none(self):
        userdata = UserData()
        assert "param" not in userdata, "ENSURE: unknown param"

        value = userdata.getas(int, "param")
        assert value is None
开发者ID:007jasonsmith,项目名称:behave,代码行数:8,代码来源:test_userdata.py

示例6: test_getas__with_known_param_and_invalid_text_raises_ValueError

# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import getas [as 别名]
 def test_getas__with_known_param_and_invalid_text_raises_ValueError(self):
     userdata = UserData(param="__BAD_NUMBER__")
     assert "param" in userdata, "ENSURE: known param"
     with pytest.raises(ValueError):
         userdata.getas(int, "param")
开发者ID:behave,项目名称:behave,代码行数:7,代码来源:test_userdata.py


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