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


Python Settings.define_setting方法代码示例

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


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

示例1: test_cannot_define_a_setting_with_default_not_valid

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
def test_cannot_define_a_setting_with_default_not_valid():
    with pytest.raises(InvalidArgument):
        Settings.define_setting(
            'kittens',
            default=8, description='Kittens are pretty great',
            options=(1, 2, 3, 4),
        )
开发者ID:Jeff-Meadows,项目名称:hypothesis,代码行数:9,代码来源:test_settings.py

示例2: test_define_setting_then_loading_profile

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
def test_define_setting_then_loading_profile():
    x = Settings()
    Settings.define_setting(
        u'fun_times',
        default=3, description=u'Something something spoon',
        options=(1, 2, 3, 4),
    )
    Settings.register_profile('hi', Settings(fun_times=2))
    assert x.fun_times == 3
    assert Settings.get_profile('hi').fun_times == 2
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:12,代码来源:test_settings.py

示例3: define_frozen_set_strategy

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
@strategy.extend(frozenset)
def define_frozen_set_strategy(specifier, settings):
    return FrozenSetStrategy(strategy(set(specifier), settings))


@strategy.extend(list)
def define_list_strategy(specifier, settings):
    return ListStrategy(
        [strategy(d, settings) for d in specifier],
        average_length=settings.average_list_length
    )

Settings.define_setting(
    'average_list_length',
    default=50.0,
    description='Average length of lists to use'
)


@strategy.extend(tuple)
def define_tuple_strategy(specifier, settings):
    return TupleStrategy(
        tuple(strategy(d, settings) for d in specifier),
        tuple_type=type(specifier)
    )


@strategy.extend(dict)
def define_dict_strategy(specifier, settings):
    strategy_dict = {}
开发者ID:sarvex,项目名称:hypothesis,代码行数:32,代码来源:collections.py

示例4: test_has_docstrings

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
# obtain one at http://mozilla.org/MPL/2.0/.

# END HEADER

from __future__ import division, print_function, absolute_import, \
    unicode_literals

import pytest
from hypothesis.errors import InvalidArgument
from hypothesis.settings import Settings, Verbosity

TEST_DESCRIPTION = 'This is a setting just for these tests'

Settings.define_setting(
    'a_setting_just_for_these_tests',
    default=3,
    description=TEST_DESCRIPTION,
)


Settings.define_setting(
    'a_setting_with_limited_options',
    default=3, description='Something something spoon',
    options=(1, 2, 3, 4),
)


def test_has_docstrings():
    assert TEST_DESCRIPTION in Settings.a_setting_just_for_these_tests.__doc__

开发者ID:Jeff-Meadows,项目名称:hypothesis,代码行数:31,代码来源:test_settings.py

示例5: TestCaseProperty

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
from hypothesis.errors import Flaky, NoSuchExample, InvalidDefinition, \
    UnsatisfiedAssumption
from hypothesis.settings import Settings, Verbosity
from hypothesis.reporting import report, verbose_report, current_verbosity
from hypothesis.internal.compat import hrange, integer_types
from hypothesis.searchstrategy.misc import JustStrategy, \
    SampledFromStrategy
from hypothesis.searchstrategy.strategies import BadData, SearchStrategy, \
    strategy, check_length, check_data_type, one_of_strategies
from hypothesis.searchstrategy.collections import TupleStrategy, \
    FixedKeysDictStrategy

Settings.define_setting(
    name='stateful_step_count',
    default=50,
    description="""
Number of steps to run a stateful program for before giving up on it breaking.
"""
)


class TestCaseProperty(object):  # pragma: no cover

    def __get__(self, obj, typ=None):
        if obj is not None:
            typ = type(obj)
        return typ._to_test_case()

    def __set__(self, obj, value):
        raise AttributeError('Cannot set TestCase')
开发者ID:Jeff-Meadows,项目名称:hypothesis,代码行数:32,代码来源:stateful.py

示例6: __init__

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
    """A strategy which produces dicts with a fixed set of keys, given a
    strategy for each of their equivalent values.

    e.g. {'foo' : some_int_strategy} would
    generate dicts with the single key 'foo' mapping to some integer.

    """

    def __init__(self, strategy_dict):
        self.dict_type = type(strategy_dict)

        if isinstance(strategy_dict, OrderedDict):
            self.keys = tuple(strategy_dict.keys())
        else:
            try:
                self.keys = tuple(sorted(strategy_dict.keys()))
            except TypeError:
                self.keys = tuple(sorted(strategy_dict.keys(), key=show))
        super(FixedKeysDictStrategy, self).__init__(
            strategy=TupleStrategy((strategy_dict[k] for k in self.keys), tuple)
        )

    def __repr__(self):
        return u"FixedKeysDictStrategy(%r, %r)" % (self.keys, self.mapped_strategy)

    def pack(self, value):
        return self.dict_type(zip(self.keys, value))


Settings.define_setting(u"average_list_length", default=25.0, description=u"Average length of lists to use")
开发者ID:kevinleestone,项目名称:hypothesis,代码行数:32,代码来源:collections.py

示例7: test_has_docstrings

# 需要导入模块: from hypothesis.settings import Settings [as 别名]
# 或者: from hypothesis.settings.Settings import define_setting [as 别名]
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at http://mozilla.org/MPL/2.0/.

# END HEADER

from __future__ import division, print_function, absolute_import

import pytest
from hypothesis.errors import InvalidArgument
from hypothesis.settings import Settings, Verbosity

TEST_DESCRIPTION = u"This is a setting just for these tests"

Settings.define_setting(u"a_setting_just_for_these_tests", default=3, description=TEST_DESCRIPTION)


Settings.define_setting(
    u"a_setting_with_limited_options", default=3, description=u"Something something spoon", options=(1, 2, 3, 4)
)


def test_has_docstrings():
    assert TEST_DESCRIPTION in Settings.a_setting_just_for_these_tests.__doc__


def setup_function(fn):
    try:
        delattr(Settings.default, u"a_setting_just_for_these_tests")
    except AttributeError:
开发者ID:kevinleestone,项目名称:hypothesis,代码行数:32,代码来源:test_settings.py


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