Skip to content

Commit

Permalink
Changed the error from AttributeError to AttributeValueError in utils…
Browse files Browse the repository at this point in the history
….validate_number_attribute()
  • Loading branch information
bharadwajyarlagadda committed Sep 29, 2016
1 parent 2fd284f commit 32b2758
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions korona/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ def validate_number_attribute(tag, attribute_name, attribute_value):
try:
return float(attribute_value)
except ValueError:
raise AttributeError('<{tag}>: {attribute} attribute should '
'be an integer or float value'
.format(tag=tag,
attribute=attribute_name))
raise AttributeValueError('<{tag}>: {attribute} attribute '
'should be an integer or float value'
.format(tag=tag,
attribute=attribute_name))
else:
# In rest all the cases, the attirbute value is not a valid int/float
# In rest all the cases, the attribute value is not a valid int/float
# value.
raise AttributeError('<{tag}>: {attribute} attribute should be an '
'integer or float value'
.format(tag=tag, attribute=attribute_name))
raise AttributeValueError('<{tag}>: {attribute} attribute should be an'
' integer or float value'
.format(tag=tag, attribute=attribute_name))


def validate_date_attribute(tag, attribute_name, attribute_value):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_global_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_construct_global_attributes(data):
TagAttributeError,
'attribute values should be one of these'),
({'tabindex': 'temp'},
AttributeError,
AttributeValueError,
'should be an integer'),
({'translate': 'temp'},
TagAttributeError,
Expand Down
16 changes: 8 additions & 8 deletions tests/test_html_tags/test_input_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from korona.html.tags import Input
from korona.templates.html.tags import input as tag
from korona.exceptions import TagAttributeError
from korona.exceptions import TagAttributeError, AttributeValueError


@parametrize('attributes', [
Expand Down Expand Up @@ -267,7 +267,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'height attribute is used only with'),
({'height': 'temp', 'type': 'image'},
AttributeError,
AttributeValueError,
'height attribute should be an integer or float value'),
# max attribute
Expand All @@ -278,7 +278,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'max attribute works with the following'),
({'max': date.today(), 'type': 'number'},
AttributeError,
AttributeValueError,
'attribute should be an integer or float value'),
({'max': '5', 'type': 'date'},
AttributeError,
Expand All @@ -289,7 +289,7 @@ def test_construct_input_tag(attributes):
# maxlength attribute
({'maxlength': 'temp'},
AttributeError,
AttributeValueError,
'attribute should be an integer or float value'),
# min attribute
Expand All @@ -300,7 +300,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'min attribute works with the following'),
({'min': date.today(), 'type': 'number'},
AttributeError,
AttributeValueError,
'attribute should be an integer or float value'),
({'min': '5', 'type': 'date'},
AttributeError,
Expand Down Expand Up @@ -354,7 +354,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'size attribute works with the following'),
({'size': 'temp', 'type': 'email'},
AttributeError,
AttributeValueError,
'should be an integer or float value'),
# src attribute
Expand All @@ -373,7 +373,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'step attribute works with the following'),
({'step': 'temp', 'type': 'range'},
AttributeError,
AttributeValueError,
'should be an integer or float value'),
# type attribute
Expand All @@ -394,7 +394,7 @@ def test_construct_input_tag(attributes):
AttributeError,
'width attribute is used only with'),
({'width': 'temp', 'type': 'image'},
AttributeError,
AttributeValueError,
'should be an integer or float value')
])
def test_construct_input_tag_error(attributes, exception, error_msg):
Expand Down

0 comments on commit 32b2758

Please sign in to comment.