本文整理汇总了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)
示例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)
示例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
示例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)
示例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
示例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")