當前位置: 首頁>>代碼示例>>Python>>正文


Python strategies.characters方法代碼示例

本文整理匯總了Python中hypothesis.strategies.characters方法的典型用法代碼示例。如果您正苦於以下問題:Python strategies.characters方法的具體用法?Python strategies.characters怎麽用?Python strategies.characters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hypothesis.strategies的用法示例。


在下文中一共展示了strategies.characters方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: urls

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def urls():
    """
    Strategy for generating urls.
    """
    return st.builds(
        parsed_url,
        scheme=st.sampled_from(uri_schemes),
        netloc=dns_names(),
        path=st.lists(
            st.text(
                max_size=64,
                alphabet=st.characters(
                    blacklist_characters="/?#", blacklist_categories=("Cs",)
                ),
            ),
            min_size=1,
            max_size=10,
        )
        .map(to_text)
        .map("".join),
    ) 
開發者ID:sarugaku,項目名稱:vistir,代碼行數:23,代碼來源:strategies.py

示例2: legal_path_chars

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def legal_path_chars():
    # Control characters
    blacklist = ["/"]
    if os.name == "nt":
        blacklist.extend(["<", ">", ":", '"', "\\", "|", "?", "*"])
    return (
        st.text(
            st.characters(
                blacklist_characters=blacklist,
                blacklist_categories=("Cs",),
                min_codepoint=32,
            ),
            min_size=0,
            max_size=64,
        )
        .filter(lambda s: not any(s.endswith(c) for c in [".", "/", "./", "/.", " "]))
        .filter(lambda s: not s.startswith("/"))
        .filter(lambda s: s not in ["", ".", "./", ".."])
    ) 
開發者ID:sarugaku,項目名稱:requirementslib,代碼行數:21,代碼來源:strategies.py

示例3: test_pre_run_hook_valid

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def test_pre_run_hook_valid(testdir, cli, schema_url, app):
    # When `--pre-run` hook is passed to the CLI call
    module = testdir.make_importable_pyfile(
        hook="""
    import string
    import schemathesis
    from hypothesis import strategies as st

    schemathesis.register_string_format(
        "digits",
        st.text(
            min_size=1,
            alphabet=st.characters(
                whitelist_characters=string.digits,
                whitelist_categories=()
            )
        )
    )
    """
    )

    result = cli.main(
        "--pre-run", module.purebasename, "run", "--hypothesis-suppress-health-check=filter_too_much", schema_url
    )

    # Then CLI should run successfully
    assert result.exit_code == ExitCode.OK, result.stdout
    # And all registered new string format should produce digits as expected
    assert all(request.query["id"].isdigit() for request in app["incoming_requests"]) 
開發者ID:kiwicom,項目名稱:schemathesis,代碼行數:31,代碼來源:test_commands.py

示例4: urls

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def urls():
    """
    Strategy for generating ``twisted.python.url.URL``\\s.
    """
    return s.builds(
        URL,
        scheme=s.just(u'https'),
        host=dns_names(),
        path=s.lists(s.text(
            max_size=64,
            alphabet=s.characters(blacklist_characters=u'/?#',
                                  blacklist_categories=('Cs',))
        ), min_size=1, max_size=10)) 
開發者ID:twisted,項目名稱:txacme,代碼行數:15,代碼來源:strategies.py

示例5: legal_path_chars

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def legal_path_chars():
    # Control characters
    blacklist = ["/"]
    if os.name == "nt":
        blacklist.extend(["<", ">", ":", '"', "\\", "|", "?", "*"])
    return st.text(
        st.characters(
            blacklist_characters=blacklist, blacklist_categories=("C",), min_codepoint=32,
        ),
        min_size=1,
        max_size=10,
    ) 
開發者ID:sarugaku,項目名稱:vistir,代碼行數:14,代碼來源:strategies.py

示例6: strategy

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def strategy(self):
        if self._enum is not None:
            return hy_st.sampled_from(self._enum)

        alphabet = None
        if self._blacklist_chars:
            alphabet = hy_st.characters(
                blacklist_characters=self._blacklist_chars)
        strategy = hy_st.text(alphabet=alphabet,
                              min_size=self._min_length,
                              max_size=self._max_length)

        return strategy 
開發者ID:olipratt,項目名稱:swagger-conformance,代碼行數:15,代碼來源:primitivestrategies.py

示例7: urls

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def urls():
    """
    Strategy for generating urls.
    """

    def url_encode(s):
        return "".join(c if c in URL_SAFE_CHARACTERS else "%%%02X" % ord(c) for c in s)

    return st.builds(
        URI,
        scheme=st.sampled_from(uri_schemes),
        host=domains(),
        port=st.integers(min_value=1, max_value=65535),
        path=st.lists(st.text(string.printable).map(url_encode)).map("/".join),
        query=st.lists(
            st.text(
                max_size=10,
                alphabet=st.characters(
                    blacklist_characters="/?#", blacklist_categories=("Cs",)
                ),
            ),
            min_size=2,
            max_size=2,
        )
        .map("=".join)
        .map(vistir.misc.to_text),
        ref=st.text(max_size=64, alphabet="abcdefghijklmnopqrstuvwxyz0123456789"),
        subdirectory=st.text(
            max_size=64, alphabet="abcdefghijklmnopqrstuvwxyz0123456789"
        ),
        extras=st.lists(
            st.text(max_size=20, alphabet="abcdefghijklmnopqrstuvwxyz0123456789_-."),
            min_size=0,
            max_size=10,
        ),
    ) 
開發者ID:sarugaku,項目名稱:requirementslib,代碼行數:38,代碼來源:strategies.py

示例8: axiomText

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def axiomText(*a, **kw):
    """
    Strategy for generating Axiom-compatible text values.
    """
    return st.text(
        alphabet=st.characters(
            blacklist_categories={'Cs'},
            blacklist_characters={u'\x00'}),
        *a, **kw) 
開發者ID:twisted,項目名稱:axiom,代碼行數:11,代碼來源:strategies.py

示例9: textlists

# 需要導入模塊: from hypothesis import strategies [as 別名]
# 或者: from hypothesis.strategies import characters [as 別名]
def textlists():
    """
    Strategy for generating lists storable with L{axiom.attributes.textlist}.
    """
    return st.lists(st.text(
        alphabet=st.characters(
            blacklist_categories={'Cs'},
            blacklist_characters={u'\x00', u'\x02', u'\x1f'}))) 
開發者ID:twisted,項目名稱:axiom,代碼行數:10,代碼來源:strategies.py


注:本文中的hypothesis.strategies.characters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。