diff --git a/hooks/percona_utils.py b/hooks/percona_utils.py index 2301655..8eecfe4 100644 --- a/hooks/percona_utils.py +++ b/hooks/percona_utils.py @@ -405,10 +405,15 @@ def assert_charm_supports_ipv6(): "versions less than Trusty 14.04") +def _cmp(x, y): + """Shim for py2 py3 compat.""" + return (x > y) - (x < y) + + def unit_sorted(units): """Return a sorted list of unit names.""" return sorted( - units, lambda a, b: cmp(int(a.split('/')[-1]), int(b.split('/')[-1]))) + units, lambda a, b: _cmp(int(a.split('/')[-1]), int(b.split('/')[-1]))) def install_mysql_ocf(): diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index 8ae9185..d8838ca 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -130,7 +130,7 @@ def patch_open(): Yields the mock for "open" and "file", respectively.''' mock_open = MagicMock(spec=open) - mock_file = MagicMock(spec=file) + mock_file = MagicMock(spec=__file__) @contextmanager def stub_open(*args, **kwargs):