當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。