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


Python strategies.from_type方法代码示例

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


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

示例1: tick_classes

# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import from_type [as 别名]
def tick_classes(request):
    """
    Fixture for Tick based datetime offsets available for a time series.
    """
    return request.param

# ----------------------------------------------------------------
# Global setup for tests using Hypothesis


# Registering these strategies makes them globally available via st.from_type,
# which is use for offsets in tests/tseries/offsets/test_offsets_properties.py 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:conftest.py

示例2: test_mean_properties

# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import from_type [as 别名]
def test_mean_properties(data, type_, strat):
    strat = strat or st.from_type(type_)
    values = data.draw(st.lists(strat, min_size=1))
    result = mean(values)  # already testing no exceptions!
    # TODO: property assertions, e.g. bounds on result, etc.
    if type_ is Fraction:
        assert min(values) <= result <= max(values)
    # What constraints make sense for an integer mean?

    # TODO: metamorphic test assertions.  For example, how should result
    # change if you add the mean to values?  a number above or below result?
    # Remove some elements from values? 
开发者ID:Zac-HD,项目名称:escape-from-automanual-testing,代码行数:14,代码来源:test-the-untestable.py

示例3: everything_except

# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import from_type [as 别名]
def everything_except(
    excluded_types: Union[type, Tuple[type, ...]]
) -> st.SearchStrategy[Any]:
    """Returns hypothesis strategy that generates values of any type other than
    those specified in ``excluded_types``."""
    return (
        st.from_type(type)
        .flatmap(st.from_type)
        .filter(lambda x: not isinstance(x, excluded_types))
    ) 
开发者ID:rsokl,项目名称:MyGrad,代码行数:12,代码来源:__init__.py


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