当前位置: 首页>>代码示例>>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;未经允许,请勿转载。