diff --git a/korona/lib/utils.py b/korona/lib/utils.py index 6b675ca..89885da 100644 --- a/korona/lib/utils.py +++ b/korona/lib/utils.py @@ -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): diff --git a/tests/test_global_attributes.py b/tests/test_global_attributes.py index 0cfe787..309900e 100644 --- a/tests/test_global_attributes.py +++ b/tests/test_global_attributes.py @@ -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, diff --git a/tests/test_html_tags/test_input_tag.py b/tests/test_html_tags/test_input_tag.py index 51b860d..11d599a 100644 --- a/tests/test_html_tags/test_input_tag.py +++ b/tests/test_html_tags/test_input_tag.py @@ -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', [ @@ -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 @@ -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, @@ -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 @@ -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, @@ -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 @@ -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 @@ -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):