def test_validate_param_required(): rule = ExampleRule(name="Test", param="Rule") with pytest.raises(ValueError) as exc: rule.validate(val=None, cast_to=str, required=True) assert str(exc.value) == "The given value is empty"
def test_validate_param_required(): rule = ExampleRule(name="Test", param="Rule") with pytest.raises(ValueError) as exc: rule.validate(val=None, cast_to=str, required=True) assert ( str(exc.value) == f"Parameter validation of {str(rule)} failed, the given value is empty" )
def test_validate_param(value): rule = ExampleRule(name="Test", param="Rule") # Casting to string is the safest result = rule.validate(value, cast_to=str) assert result == str(value)
def test_validate_param_empty(): rule = ExampleRule(name="Test", param="Rule") result = rule.validate(val=None, cast_to=str) assert result == "None"
def test_validate_no_casting(value): rule = ExampleRule(name="Test", param="Rule") result = rule.validate(val=value) assert result is value