コード例 #1
0
def test_validator_rejection_number3_length(
        val, first_invalid_ind, validator_number3: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3.validate_coerce(val)

    assert ('The prop[%d] property of parent must be in the range [0, 1]' %
            first_invalid_ind in str(validation_failure.value))
コード例 #2
0
def test_validator_rejection_number3_length(
        val, validator_number3: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3.validate_coerce(val)

    assert 'must be a list or tuple of length 3.' in str(
        validation_failure.value)
コード例 #3
0
def test_validator_rejection_number3_length(
        val, first_invalid_ind, validator_number3_free: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3_free.validate_coerce(val)

    assert (
        "Invalid value of type {typ} received for the 'prop[{first_invalid_ind}]' property of parent"
        .format(typ=type_str(val[first_invalid_ind]),
                first_invalid_ind=first_invalid_ind)) in str(
                    validation_failure.value)
コード例 #4
0
def test_validator_acceptance_number3(val,
                                      validator_number3: InfoArrayValidator):
    coerce_val = validator_number3.validate_coerce(val)
    assert coerce_val == list(val)
    assert validator_number3.present(coerce_val) == tuple(val)
コード例 #5
0
def test_validator_rejection_any2_length(val,
                                         validator_any2: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_any2.validate_coerce(val)

    assert 'Invalid value' in str(validation_failure.value)
コード例 #6
0
def test_validator_rejection_any2_type(val,
                                       validator_any2: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_any2.validate_coerce(val)

    assert 'must be a list or tuple.' in str(validation_failure.value)
コード例 #7
0
def test_validator_acceptance_any2(val, validator_any2: InfoArrayValidator):
    coerce_val = validator_any2.validate_coerce(val)
    assert coerce_val == list(val)
    assert validator_any2.present(coerce_val) == tuple(val)
コード例 #8
0
def test_validator_rejection_any2_type(
        val, validator_number3_free: InfoArrayValidator):
    with pytest.raises(ValueError) as validation_failure:
        validator_number3_free.validate_coerce(val)

    assert 'Invalid value' in str(validation_failure.value)