def test_phonefield_not_valid(required, nullable, value, ex_mes): field = PhoneField(required, nullable) with pytest.raises(ValidationError) as e: field.validate(value) assert str(e.value) == ex_mes
def test_phonesfield_valid(required, nullable, value): field = PhoneField(required, nullable) assert not field.validate(value)