mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix tests for Py3
readPlistFromString has been deprecated on Python3. Use loads instead.
This commit is contained in:
parent
7b40218790
commit
5796696617
2 changed files with 9 additions and 8 deletions
|
@ -325,7 +325,7 @@ def _available_services():
|
|||
if six.PY2:
|
||||
plist = plistlib.readPlistFromString(plist_xml)
|
||||
else:
|
||||
plist = plistlib.readPlistFromBytes(
|
||||
plist = plistlib.loads(
|
||||
salt.utils.stringutils.to_bytes(plist_xml))
|
||||
|
||||
try:
|
||||
|
|
|
@ -17,6 +17,7 @@ from salt.exceptions import SaltInvocationError, CommandExecutionError
|
|||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext.six.moves import range
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
|
@ -317,7 +318,7 @@ class MacUtilsTestCase(TestCase):
|
|||
@patch('os.path.exists')
|
||||
@patch('plistlib.readPlist')
|
||||
@patch('salt.modules.cmdmod.run')
|
||||
@patch('plistlib.readPlistFromString')
|
||||
@patch('plistlib.readPlistFromString' if six.PY2 else 'plistlib.loads')
|
||||
def test_available_services_non_xml(self,
|
||||
mock_read_plist_from_string,
|
||||
mock_run,
|
||||
|
@ -404,13 +405,13 @@ class MacUtilsTestCase(TestCase):
|
|||
@patch('os.path.exists')
|
||||
@patch('plistlib.readPlist')
|
||||
@patch('salt.modules.cmdmod.run')
|
||||
@patch('plistlib.readPlistFromString')
|
||||
@patch('plistlib.readPlistFromString' if six.PY2 else 'plistlib.loads')
|
||||
def test_available_services_non_xml_malformed_plist(self,
|
||||
mock_read_plist_from_string,
|
||||
mock_run,
|
||||
mock_read_plist,
|
||||
mock_exists,
|
||||
mock_os_walk):
|
||||
mock_read_plist_from_string,
|
||||
mock_run,
|
||||
mock_read_plist,
|
||||
mock_exists,
|
||||
mock_os_walk):
|
||||
'''
|
||||
test available_services
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue