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


Python settings.Settings类代码示例

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


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

示例1: test_cannot_define_a_setting_with_default_not_valid

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,代码行数:7,代码来源:test_settings.py

示例2: test_loading_profile_keeps_expected_behaviour

def test_loading_profile_keeps_expected_behaviour():
    Settings.register_profile('ci', Settings(max_examples=10000))
    Settings.load_profile('ci')
    assert Settings().max_examples == 10000
    with Settings(max_examples=5):
        assert Settings().max_examples == 5
    assert Settings().max_examples == 10000
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:7,代码来源:test_settings.py

示例3: test_define_setting_then_loading_profile

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,代码行数:10,代码来源:test_settings.py

示例4: test_load_profile

def test_load_profile():
    Settings.load_profile('default')
    assert Settings.default.max_examples == 200
    assert Settings.default.max_shrinks == 500
    assert Settings.default.min_satisfying_examples == 5

    Settings.register_profile(
        'test',
        Settings(
            max_examples=10,
            max_shrinks=5
        )
    )

    Settings.load_profile('test')

    assert Settings.default.max_examples == 10
    assert Settings.default.max_shrinks == 5
    assert Settings.default.min_satisfying_examples == 5

    Settings.load_profile('default')

    assert Settings.default.max_examples == 200
    assert Settings.default.max_shrinks == 500
    assert Settings.default.min_satisfying_examples == 5
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:25,代码来源:test_settings.py

示例5: define_frozen_set_strategy

@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,代码行数:30,代码来源:collections.py

示例6: test_cannot_set_non_settings

def test_cannot_set_non_settings():
    s = Settings()
    with pytest.raises(AttributeError):
        s.databas_file = 'some_file'
开发者ID:Jeff-Meadows,项目名称:hypothesis,代码行数:4,代码来源:test_settings.py

示例7: test_has_docstrings

# 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,代码行数:29,代码来源:test_settings.py

示例8: test_load_non_existent_profile

def test_load_non_existent_profile():
    with pytest.raises(hypothesis.errors.InvalidArgument):
        Settings.get_profile('nonsense')
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:3,代码来源:test_settings.py

示例9: test_modifying_registered_profile_does_not_change_profile

def test_modifying_registered_profile_does_not_change_profile():
    ci_profile = Settings(max_examples=10000)
    Settings.register_profile('ci', ci_profile)
    ci_profile.max_examples = 1
    Settings.load_profile('ci')
    assert Settings().max_examples == 10000
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:6,代码来源:test_settings.py

示例10: test_loading_profile_resets_defaults

def test_loading_profile_resets_defaults():
    assert Settings.default.min_satisfying_examples == 5
    Settings.default.min_satisfying_examples = 100
    assert Settings.default.min_satisfying_examples == 100
    Settings.load_profile('default')
    assert Settings.default.min_satisfying_examples == 5
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:6,代码来源:test_settings.py

示例11: test_can_assign_database

def test_can_assign_database(db):
    x = Settings()
    assert x.database is not None
    x.database = db
    assert x.database is db
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:5,代码来源:test_settings.py

示例12: TestCaseProperty

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,代码行数:30,代码来源:stateful.py

示例13: __init__

    """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,代码行数:30,代码来源:collections.py

示例14: setup_function

def setup_function(fn):
    Settings.load_profile('default')
    Settings.register_profile('test_settings', Settings())
    Settings.load_profile('test_settings')
开发者ID:GMadorell,项目名称:hypothesis,代码行数:4,代码来源:test_settings.py

示例15: test_has_docstrings

import os

import pytest

import hypothesis
from hypothesis.errors import InvalidArgument
from hypothesis.database import ExampleDatabase
from hypothesis.settings import Settings, Verbosity


def test_has_docstrings():
    assert Settings.verbosity.__doc__


original_default = Settings.get_profile('default').max_examples


def setup_function(fn):
    Settings.load_profile('default')
    Settings.register_profile('test_settings', Settings())
    Settings.load_profile('test_settings')


def test_cannot_set_non_settings():
    s = Settings()
    with pytest.raises(AttributeError):
        s.databas_file = u'some_file'


def test_settings_uses_defaults():
开发者ID:GMadorell,项目名称:hypothesis,代码行数:30,代码来源:test_settings.py


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