예제 #1
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
예제 #2
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
예제 #3
0
def test_picks_up_changes_to_defaults_when_switching_profiles():
    original_default = Settings.default.max_examples
    Settings.load_profile('nonstrict')
    Settings.register_profile('test_settings', Settings())
    Settings.load_profile('test_settings')

    Settings.register_profile('other_test_settings', Settings())
    Settings.default.max_examples = 18
    assert Settings.default.max_examples == 18
    Settings.load_profile('other_test_settings')
    assert Settings.default.max_examples == original_default
    Settings.load_profile('test_settings')
    assert Settings.default.max_examples == 18
예제 #4
0
def test_picks_up_changes_to_defaults_when_switching_profiles():
    original_default = Settings.default.max_examples
    Settings.load_profile('nonstrict')
    Settings.register_profile('test_settings', Settings())
    Settings.load_profile('test_settings')

    Settings.register_profile('other_test_settings', Settings())
    Settings.default.max_examples = 18
    assert Settings.default.max_examples == 18
    Settings.load_profile('other_test_settings')
    assert Settings.default.max_examples == original_default
    Settings.load_profile('test_settings')
    assert Settings.default.max_examples == 18
예제 #5
0
class IgnoreImplicitWait:
    def __init__(self, driver, default_wait):
        self._driver = driver
        self._default_wait = default_wait

        self._driver.implicitly_wait(0)

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self._driver.implicitly_wait(self._default_wait)


Settings.register_profile('selenium', Settings(max_examples=1, timeout=0))
Settings.load_profile('selenium')


class SeleniumTestCase(StaticLiveServerTestCase):
    selenium_implicit_wait = 30
    _driver = None

    def __init__(self, *args, **kwargs):
        self.browser_tag = _browser_tag
        super().__init__(*args, **kwargs)

    @property
    def driver(self):
        if not SeleniumTestCase._driver:
            if _use_remote_driver:
예제 #6
0
import pytest

import hypothesis.specifiers as s
import hypothesis.strategies as st
from hypothesis import find, Settings, strategy
from hypothesis.errors import InvalidArgument
from tests.common.basic import Bitfields
from hypothesis.internal.compat import text_type, binary_type, \
    integer_types
from hypothesis.searchstrategy.narytree import Leaf, Branch, NAryTree

original_profile = Settings.default

Settings.register_profile(
    'nonstrict', Settings(strict=False)
)


def setup_function(fn):
    Settings.load_profile('nonstrict')


def teardown_function(fn):
    Settings.load_profile('default')


@pytest.mark.parametrize(u'typ', [
    complex, float, bool, Random, type(None), text_type, binary_type,
    Decimal, Fraction,
])
예제 #7
0
파일: conftest.py 프로젝트: jwg4/hypothesis
from __future__ import division, print_function, absolute_import

import gc
import os
import warnings
from tempfile import mkdtemp

import pytest

from hypothesis import Settings
from hypothesis.settings import set_hypothesis_home_dir

warnings.filterwarnings(u'error', category=UnicodeWarning)

set_hypothesis_home_dir(mkdtemp())

Settings.default.timeout = -1
Settings.default.strict = True

Settings.register_profile(
    'speedy', Settings(
        timeout=1, max_examples=5,
    ))
Settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))


@pytest.fixture(scope=u'function', autouse=True)
def some_fixture():
    gc.collect()
예제 #8
0
class IgnoreImplicitWait:
    def __init__(self, driver, default_wait):
        self._driver = driver
        self._default_wait = default_wait

        self._driver.implicitly_wait(0)

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self._driver.implicitly_wait(self._default_wait)


Settings.register_profile('selenium', Settings(max_examples=1, timeout=0))
Settings.load_profile('selenium')


class SeleniumTestCase(StaticLiveServerTestCase):
    selenium_implicit_wait = 30
    _driver = None

    def __init__(self, *args, **kwargs):
        self.browser_tag = _browser_tag
        super().__init__(*args, **kwargs)

    @property
    def driver(self):
        if not SeleniumTestCase._driver:
            if _use_remote_driver:
예제 #9
0
from __future__ import division, print_function, absolute_import

import warnings

import pytest

import hypothesis.strategies as st
from hypothesis import given, Settings
from hypothesis.errors import HypothesisDeprecationWarning
from hypothesis.internal.compat import PY3, unicode_safe_repr
from hypothesis.internal.reflection import arg_string

original_profile = Settings.default

Settings.register_profile(
    'nonstrict', Settings(strict=False)
)


def setup_function(fn):
    Settings.load_profile('nonstrict')
    warnings.simplefilter('always', HypothesisDeprecationWarning)


def teardown_function(fn):
    Settings.load_profile('default')
    warnings.simplefilter('once', HypothesisDeprecationWarning)


class BadRepr(object):
예제 #10
0
from __future__ import division, print_function, absolute_import

import gc
import os
import warnings
from tempfile import mkdtemp

import pytest

from hypothesis import Settings
from hypothesis.settings import set_hypothesis_home_dir

warnings.filterwarnings(u'error', category=UnicodeWarning)

set_hypothesis_home_dir(mkdtemp())

Settings.default.timeout = -1
Settings.default.strict = True

Settings.register_profile('speedy', Settings(
    timeout=1,
    max_examples=5,
))
Settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))


@pytest.fixture(scope=u'function', autouse=True)
def some_fixture():
    gc.collect()
예제 #11
0
import os

from hypothesis import Settings, Verbosity


Settings.register_profile("dev", Settings(max_examples=10))
Settings.register_profile(
    "debug",
    Settings(max_examples=10, verbosity=Verbosity.verbose),
)
Settings.load_profile(os.getenv(u'HYPOTHESIS_PROFILE', 'dev'))
예제 #12
0
from tempfile import mkdtemp

import pytest

from hypothesis import Settings
from hypothesis.settings import set_hypothesis_home_dir

warnings.filterwarnings(u'error', category=UnicodeWarning)

set_hypothesis_home_dir(mkdtemp())

Settings.default.timeout = -1
Settings.default.strict = True

Settings.register_profile(
    'speedy', Settings(
        timeout=1, max_examples=5,
    ))


Settings.register_profile(
    'nonstrict', Settings(strict=False)
)

Settings.load_profile(os.getenv('HYPOTHESIS_PROFILE', 'default'))


@pytest.fixture(scope=u'function', autouse=True)
def some_fixture():
    gc.collect()
예제 #13
0
"""Message passing with lazy connection handling and encryption"""
try:  # pragma: no cover
    import os
    from hypothesis import Settings
    Settings.register_profile("ci", Settings(
        max_examples=10000
    ))
    Settings.load_profile(os.getenv(u'HYPOTHESIS_PROFILE', 'default'))
except (ImportError, AttributeError):  # pragma: no cover
    pass

import asyncio
import ssl

from .chirp import Chirp  # noqa
from .const import Config, MessageType  # noqa
from .struct import Message, SelfConnectError  # noqa

SendErrors = (
    ssl.SSLError,
    asyncio.TimeoutError,
    asyncio.IncompleteReadError,
    ConnectionRefusedError,
    ConnectionResetError,
    BrokenPipeError,
)
"""Convenience tuple to except all common send errors."""

__all__ = (
    'Chirp',
    'Message',