Esempio n. 1
0
def test_coercion_aok_list(val, expected, validator_aok: IntegerValidator):
    v = validator_aok.validate_coerce(val)
    if isinstance(val, np.ndarray):
        assert v.dtype == np.int32
        assert np.array_equal(validator_aok.present(v),
                              np.array(expected, dtype=np.int32))
    else:
        assert isinstance(v, list)
        assert validator_aok.present(v) == expected
def validator_min():
    return IntegerValidator('prop', 'parent', min=-1)
def validator():
    return IntegerValidator('prop', 'parent')
Esempio n. 4
0
def test_rejection_max(val, validator_max: IntegerValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_max.validate_coerce(val)

    assert 'in the interval [-9223372036854775808, 2]' in str(
        validation_failure.value)
Esempio n. 5
0
def test_acceptance_max(val, validator_max: IntegerValidator):
    assert validator_max.validate_coerce(val) == approx(val)
Esempio n. 6
0
def test_rejection_by_value(val, validator: IntegerValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator.validate_coerce(val)

    assert 'Invalid value' in str(validation_failure.value)
Esempio n. 7
0
def validator_min():
    return IntegerValidator("prop", "parent", min=-1)
Esempio n. 8
0
def integer_validator(request):
    return IntegerValidator("prop", "parent", array_ok=True)
Esempio n. 9
0
def test_integer_validator_rejection_aok(val, validator_aok: IntegerValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_aok.validate_coerce(val)

    assert 'Invalid element(s)' in str(validation_failure.value)
Esempio n. 10
0
def test_acceptance_aok_list(val, validator_aok: IntegerValidator):
    assert np.array_equal(validator_aok.validate_coerce(val), val)
Esempio n. 11
0
def test_acceptance_aok_scalars(val, validator_aok: IntegerValidator):
    assert validator_aok.validate_coerce(val) == val
Esempio n. 12
0
def validator_aok(request):
    return IntegerValidator("prop", "parent", min=-2, max=10, array_ok=True)
Esempio n. 13
0
def validator_max():
    return IntegerValidator("prop", "parent", max=2)
def validator_max():
    return IntegerValidator('prop', 'parent', max=2)
Esempio n. 15
0
def test_rejection_aok_min_max(val, validator_aok: IntegerValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_aok.validate_coerce(val)

    assert 'in the interval [-2, 10]' in str(validation_failure.value)
def validator_aok(request):
    return IntegerValidator('prop', 'parent', min=-2, max=10, array_ok=True)
Esempio n. 17
0
def test_acceptance(val, validator: IntegerValidator):
    assert validator.validate_coerce(val) == val
Esempio n. 18
0
def integer_validator(request):
    return IntegerValidator('prop', 'parent', array_ok=True)
Esempio n. 19
0
def validator():
    return IntegerValidator("prop", "parent")