def test_instances_of_type_human_readable(type, expected_type_name): """Check the string representation of the _InstancesOf constraint.""" constraint = _InstancesOf(type) assert str(constraint) == f"an instance of '{expected_type_name}'"
bad_value = generate_invalid_param_val( real_interval, constraints=[real_interval, integer_interval]) assert not real_interval.is_satisfied_by(bad_value) assert not integer_interval.is_satisfied_by(bad_value) bad_value = generate_invalid_param_val( integer_interval, constraints=[real_interval, integer_interval]) assert not real_interval.is_satisfied_by(bad_value) assert not integer_interval.is_satisfied_by(bad_value) @pytest.mark.parametrize( "constraints", [ [_ArrayLikes()], [_InstancesOf(list)], [Interval(Real, None, None, closed="both")], [ Interval(Integral, 0, None, closed="left"), Interval(Real, None, 0, closed="neither"), ], ], ) def test_generate_invalid_param_val_all_valid(constraints): """Check that the function raises NotImplementedError when there's no invalid value for the constraint. """ with pytest.raises(NotImplementedError): generate_invalid_param_val(constraints[0], constraints=constraints)