Merge pull request #40002 from s0undt3ch/features/py3

Minor Py3 test module fix
This commit is contained in:
Mike Place 2017-03-14 12:44:36 -06:00 committed by GitHub
commit 9495664f0f
3 changed files with 14 additions and 5 deletions

View file

@ -1613,7 +1613,7 @@ class LazyLoader(salt.utils.lazy.LazyDict):
error_reason = (
'Exception raised when processing __virtual__ function'
' for {0}. Module will not be loaded: {1}'.format(
module_name, exc))
mod.__name__, exc))
log.error(error_reason, exc_info_on_loglevel=logging.DEBUG)
virtual = None
# Get the module's virtual name

View file

@ -23,13 +23,17 @@ import salt.ext.six as six
class StrictVersion(_StrictVersion):
def parse(self, vstring):
_StrictVersion.parse(self, vstring)
if six.PY3:
# Convert every part of the version to string in order to be able to compare
self.version = [str(vp) for vp in self.version]
def _cmp(self, other):
if isinstance(other, six.string_types):
other = StrictVersion(other)
return _StrictVersion._cmp(self, other)
class LooseVersion(_LooseVersion):
@ -38,3 +42,8 @@ class LooseVersion(_LooseVersion):
if six.PY3:
# Convert every part of the version to string in order to be able to compare
self.version = [str(vp) for vp in self.version]
def _cmp(self, other):
if isinstance(other, six.string_types):
other = LooseVersion(other)
return _LooseVersion._cmp(self, other)

View file

@ -42,14 +42,14 @@ class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin):
def test_empty_config(self, *args, **kwargs):
config = {}
ret = status.beacon(config)
self.assertEqual(ret[0]['data'].keys(), ['loadavg', 'meminfo', 'cpustats', 'vmstats', 'time'])
self.assertEqual(sorted(list(ret[0]['data'])), sorted(['loadavg', 'meminfo', 'cpustats', 'vmstats', 'time']))
def test_deprecated_dict_config(self):
config = {'time': ['all']}
ret = status.beacon(config)
self.assertEqual(ret[0]['data'].keys(), ['time'])
self.assertEqual(list(ret[0]['data']), ['time'])
def test_list_config(self):
config = [{'time': ['all']}]
ret = status.beacon(config)
self.assertEqual(ret[0]['data'].keys(), ['time'])
self.assertEqual(list(ret[0]['data']), ['time'])