Allow escaped comments in inventory files.

This commit is contained in:
Michael DeHaan 2014-03-05 20:10:25 -05:00
parent 4e8ed92130
commit 94a7fb60fe
3 changed files with 34 additions and 1 deletions

View file

@ -16,6 +16,29 @@ sys.setdefaultencoding("utf8")
class TestUtils(unittest.TestCase):
def test_before_comment(self):
''' see if we can detect the part of a string before a comment. Used by INI parser in inventory '''
input = "before # comment"
expected = "before "
actual = ansible.utils.before_comment(input)
assert expected == actual
input = "before \# not a comment"
expected = "before # not a comment"
actual = ansible.utils.before_comment(input)
assert expected == actual
input = ""
expected = ""
actual = ansible.utils.before_comment(input)
assert expected == actual
input = "#"
expected = ""
actual = ansible.utils.before_comment(input)
assert expected == actual
#####################################
### check_conditional tests