Commit c42dbf80 by Michael DeHaan

Merge pull request #6586 from sivel/probline-logic-fix

Fix logic in process_common_errors for unbalanced quotes
parents 266123e5 2aaecc5a
...@@ -424,7 +424,7 @@ Or: ...@@ -424,7 +424,7 @@ Or:
match = True match = True
elif middle.startswith('"') and not middle.endswith('"'): elif middle.startswith('"') and not middle.endswith('"'):
match = True match = True
if len(middle) > 0 and middle[0] in [ '"', "'" ] and middle[-1] in [ '"', "'" ] and probline.count("'") > 2 or probline.count("'") > 2: if len(middle) > 0 and middle[0] in [ '"', "'" ] and middle[-1] in [ '"', "'" ] and probline.count("'") > 2 or probline.count('"') > 2:
unbalanced = True unbalanced = True
if match: if match:
msg = msg + """ msg = msg + """
......
...@@ -301,8 +301,7 @@ class TestUtils(unittest.TestCase): ...@@ -301,8 +301,7 @@ class TestUtils(unittest.TestCase):
self.assertTrue('same kind of quote' in ansible.utils.process_common_errors('', "foo: '{{bar}}'baz", 6)) self.assertTrue('same kind of quote' in ansible.utils.process_common_errors('', "foo: '{{bar}}'baz", 6))
# unbalanced # unbalanced
# The first test fails and is commented out for now, logic is wrong and the test fails self.assertTrue('We could be wrong' in ansible.utils.process_common_errors('', 'foo: "bad" "wolf"', 6))
#self.assertTrue('We could be wrong' in ansible.utils.process_common_errors('', 'foo: "bad" "wolf"', 6))
self.assertTrue('We could be wrong' in ansible.utils.process_common_errors('', "foo: 'bad' 'wolf'", 6)) self.assertTrue('We could be wrong' in ansible.utils.process_common_errors('', "foo: 'bad' 'wolf'", 6))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment