Use regex to split

This commit is contained in:
twangboy 2017-11-09 16:24:19 -07:00
parent ff4f13877f
commit 0a9e862bf4
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -7,6 +7,7 @@
# Import Python libs
from __future__ import absolute_import
import os
import re
# Import Salt Testing libs
from tests.support.unit import TestCase
@ -44,7 +45,7 @@ class DocTestCase(TestCase):
salt_dir += '/'
cmd = 'grep -r :doc: ' + salt_dir
grep_call = salt.modules.cmdmod.run_stdout(cmd=cmd).split('\n')
grep_call = salt.modules.cmdmod.run_stdout(cmd=cmd).split(os.linesep)
test_ret = {}
for line in grep_call:
@ -52,12 +53,10 @@ class DocTestCase(TestCase):
if line.startswith('Binary'):
continue
if salt.utils.is_windows():
# Need the space after the colon so it doesn't split the drive
# letter
key, val = line.split(': ', 1)
else:
key, val = line.split(':', 1)
# Only split on colons not followed by a '\' as is the case with
# Windows Drives
regex = re.compile(r':(?!\\)')
key, val = regex.split(line, 1)
# Don't test man pages, this file,
# the page that documents to not use ":doc:", or