Fail if there is a duplicate tag.
This commit is contained in:
@@ -77,10 +77,16 @@ class TestParseTagValue(unittest.TestCase):
|
||||
{'foo': 'bar', 'baz': 'foo=bar'},
|
||||
parse_tag_value('foo=bar;baz=foo=bar'))
|
||||
|
||||
def test_no_value(self):
|
||||
def test_missing_value_is_an_error(self):
|
||||
self.assertRaises(
|
||||
InvalidTagValueList,
|
||||
parse_tag_value, 'foo=bar;baz')
|
||||
|
||||
def test_duplicate_tag_is_an_error(self):
|
||||
self.assertRaises(
|
||||
InvalidTagValueList,
|
||||
parse_tag_value, 'foo=bar;foo=baz')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -42,5 +42,7 @@ def parse_tag_value(tag_list):
|
||||
key, value = tag_spec.split('=', 1)
|
||||
except ValueError:
|
||||
raise InvalidTagValueList()
|
||||
if key.strip() in tags:
|
||||
raise InvalidTagValueList()
|
||||
tags[key.strip()] = value.strip()
|
||||
return tags
|
||||
|
||||
Reference in New Issue
Block a user