From: Didier Raboud Date: Wed, 23 May 2012 09:30:47 +0000 (+0200) Subject: Py3: Replace cmp usage by its equivalent. X-Git-Tag: archive/raspbian/10.2018112800+rpi1^2~104 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6cda53f1fe62d93d180581ff82114d69e25af1d1;p=lsb.git Py3: Replace cmp usage by its equivalent. --- diff --git a/lsb_release.py b/lsb_release.py index 68664e6..eb3c45a 100644 --- a/lsb_release.py +++ b/lsb_release.py @@ -185,7 +185,7 @@ def compare_release(x, y): if suite_x in RELEASES_ORDER and suite_y in RELEASES_ORDER: return RELEASES_ORDER.index(suite_y)-RELEASES_ORDER.index(suite_x) else: - return cmp(suite_x, suite_y) + return (suite_x > suite_y) - (suite_x < suite_y) return 0 diff --git a/test/test_lsb_release.py b/test/test_lsb_release.py index 7e85769..d095664 100644 --- a/test/test_lsb_release.py +++ b/test/test_lsb_release.py @@ -123,7 +123,7 @@ class TestLSBRelease(unittest.TestCase): # Test that sequences not in RELEASES_ORDER lead to reliable output x[1]['suite'] = rnd_string(1,12) y[1]['suite'] = rnd_string(1,12) - supposed_output = cmp(x[1]['suite'],y[1]['suite']) + supposed_output = (x[1]['suite'] > y[1]['suite']) - (x[1]['suite'] < y[1]['suite']) self.assertEqual(lr.compare_release(x,y), supposed_output, 'compare_release(' + x[1]['suite'] + ',' + y[1]['suite'] + ') =? ' + str(supposed_output))