def test_cannot_define_a_setting_with_default_not_valid():
    with pytest.raises(InvalidArgument):
        Settings.define_setting(
            u'kittens',
            default=8, description=u'Kittens are pretty great',
            options=(1, 2, 3, 4),
        )
Esempio n. 2
0
def test_cannot_define_a_setting_with_default_not_valid():
    with pytest.raises(InvalidArgument):
        Settings.define_setting(
            u'kittens',
            default=8,
            description=u'Kittens are pretty great',
            options=(1, 2, 3, 4),
        )
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
Esempio n. 4
0
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
def test_can_define_settings():
    test_description = u'This is a setting just for these tests'
    assert not Settings.default.strict

    x = Settings()
    assert not x.strict

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

    assert test_description in Settings.a_setting_just_for_these_tests.__doc__

    assert x.a_setting_just_for_these_tests == 3
    assert Settings().a_setting_just_for_these_tests == 3
Esempio n. 6
0
def test_can_define_settings():
    test_description = u'This is a setting just for these tests'
    assert not Settings.default.strict

    x = Settings()
    assert not x.strict

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

    assert test_description in Settings.a_setting_just_for_these_tests.__doc__

    assert x.a_setting_just_for_these_tests == 3
    assert Settings().a_setting_just_for_these_tests == 3
Esempio n. 7
0
# 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, \
    unicode_literals

import pytest
from hypothesis import Settings

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

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


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


def setup_function(fn):
    try:
        delattr(Settings.default, 'a_setting_just_for_these_tests')
    except AttributeError:
        pass