mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Allow escaped comments in inventory files.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user