mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 06:11:26 -07:00
Allow escaped comments in inventory files.
This commit is contained in:
parent
4e8ed92130
commit
94a7fb60fe
3 changed files with 34 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue