Fix lint in unit tests re: py3-first and py2 compat

Use local heler for now due to the transitional state of this charm
from py2 to py3, where cmp does not exist.

Change-Id: I86161b8886da69833c4cc074c0f7ede15f456c9d
This commit is contained in:
Ryan Beisner 2018-11-01 21:46:59 -05:00
parent 52bea295b5
commit 8ba9abb45b
No known key found for this signature in database
GPG Key ID: 952BACDC1C1A05FB
2 changed files with 7 additions and 2 deletions

View File

@ -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():

View File

@ -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):