How to use the hypothesis.errors.InvalidArgument function in hypothesis

To help you get started, we’ve selected a few hypothesis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HypothesisWorks / hypothesis / tests / py3 / test_annotations.py View on Github external
def test_given_notices_missing_kwonly_args():
    with pytest.raises(InvalidArgument):
        @given(a=st.none())
        def reqs_kwonly(*, a, b):
            pass
github HypothesisWorks / hypothesis / tests / cover / test_explicit_examples.py View on Github external
def test_no_empty_examples():
    with pytest.raises(InvalidArgument):
        example()
github HypothesisWorks / hypothesis / tests / cover / test_runner_strategy.py View on Github external
def test_cannot_use_without_a_runner():
    @given(st.runner())
    def f(x):
        pass
    with pytest.raises(InvalidArgument):
        f()
github HypothesisWorks / hypothesis / tests / cover / test_reproduce_failure.py View on Github external
def test_decoding_may_fail(t):
    try:
        decode_failure(t)
        reject()
    except InvalidArgument:
        pass
github HypothesisWorks / hypothesis / tests / cover / test_float_nastiness.py View on Github external
def test_float_free_interval_is_invalid():
    lo = (2 ** 54) + 1
    hi = lo + 2
    assert float(lo) < lo < hi < float(hi), 'There are no floats in [lo .. hi]'
    with pytest.raises(InvalidArgument):
        st.floats(lo, hi).example()
github HypothesisWorks / hypothesis / tests / cover / test_chooser.py View on Github external
def test_cannot_choose_empty():
    with pytest.raises(InvalidArgument):
        chooser([])
github chobeat / hypothesis-csv / src / hypothesis_csv / _data_rows.py View on Github external
def get_lines_num(draw, lines_param):
    raise InvalidArgument("Lines param must be an integer or None")
github HypothesisWorks / hypothesis / hypothesis-python / src / hypothesis / internal / validation.py View on Github external
@check_function
def try_convert(typ, value, name):
    if value is None:
        return None
    if isinstance(value, typ):
        return value
    try:
        return typ(value)
    except (TypeError, OverflowError, ValueError, ArithmeticError):
        raise InvalidArgument(
            "Cannot convert %s=%r of type %s to type %s"
            % (name, value, type(value).__name__, typ.__name__)
        )
github HypothesisWorks / hypothesis / hypothesis-python / src / hypothesis / internal / validation.py View on Github external
def check_valid_bound(value, name):
    """Checks that value is either unspecified, or a valid interval bound.

    Otherwise raises InvalidArgument.
    """
    if value is None or isinstance(value, integer_types + (Rational,)):
        return
    if not isinstance(value, (Real, decimal.Decimal)):
        raise InvalidArgument("%s=%r must be a real number." % (name, value))
    if math.isnan(value):
        raise InvalidArgument(u"Invalid end point %s=%r" % (name, value))
github HypothesisWorks / hypothesis / hypothesis-python / src / hypothesis / internal / validation.py View on Github external
def check_valid_interval(lower_bound, upper_bound, lower_name, upper_name):
    """Checks that lower_bound and upper_bound are either unspecified, or they
    define a valid interval on the number line.

    Otherwise raises InvalidArgument.
    """
    if lower_bound is None or upper_bound is None:
        return
    if upper_bound < lower_bound:
        raise InvalidArgument(
            "Cannot have %s=%r < %s=%r"
            % (upper_name, upper_bound, lower_name, lower_bound)
        )