John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234521

Change subject: Fix ComparableMixin
......................................................................

Fix ComparableMixin

Change-Id: Ia00ab2dd68938b0520253f7017d685aa03c36592
---
M pywikibot/tools/__init__.py
M tests/namespace_tests.py
2 files changed, 17 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/21/234521/1

diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index aced6c0..ed34f3c 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -138,11 +138,11 @@
 
     def __lt__(self, other):
         """Compare if other is less than self."""
-        return other >= self._cmpkey()
+        return other > self._cmpkey()
 
     def __le__(self, other):
         """Compare if other is less equals self."""
-        return other > self._cmpkey()
+        return other >= self._cmpkey()
 
     def __eq__(self, other):
         """Compare if other is equal to self."""
@@ -150,11 +150,11 @@
 
     def __ge__(self, other):
         """Compare if other is greater equals self."""
-        return other < self._cmpkey()
+        return other <= self._cmpkey()
 
     def __gt__(self, other):
         """Compare if other is greater than self."""
-        return other <= self._cmpkey()
+        return other < self._cmpkey()
 
     def __ne__(self, other):
         """Compare if other is not equal to self."""
diff --git a/tests/namespace_tests.py b/tests/namespace_tests.py
index f2e2373..024ba7f 100644
--- a/tests/namespace_tests.py
+++ b/tests/namespace_tests.py
@@ -132,13 +132,17 @@
 
         self.assertEqual(a, 0)
         self.assertEqual(a, '')
+        self.assertFalse(a < 0)
+        self.assertFalse(a > 0)
         self.assertNotEqual(a, None)
+
+        self.assertGreater(a, -1)
 
         x = Namespace(id=6, custom_name=u'dummy', canonical_name=u'File',
                       aliases=[u'Image', u'Immagine'])
         y = Namespace(id=6, custom_name=u'ملف', canonical_name=u'File',
                       aliases=[u'Image', u'Immagine'])
-        z = Namespace(id=7, custom_name=u'dummy', canonical_name=u'File',
+        z = Namespace(id=7, custom_name=u'dummy 7', canonical_name=u'File',
                       aliases=[u'Image', u'Immagine'])
 
         self.assertEqual(x, x)
@@ -157,11 +161,19 @@
         self.assertEqual(x, u'image')
         self.assertEqual(x, u'Image')
 
+        self.assertFalse(x < 6)
+        self.assertFalse(x > 6)
+
         self.assertEqual(y, u'ملف')
 
         self.assertLess(a, x)
+        self.assertLess(x, z)
+        self.assertLessEqual(a, x)
         self.assertGreater(x, a)
+        self.assertGreater(x, 0)
         self.assertGreater(z, x)
+        self.assertGreaterEqual(x, a)
+        self.assertGreaterEqual(y, x)
 
         self.assertIn(6, [x, y, z])
         self.assertNotIn(8, [x, y, z])

-- 
To view, visit https://gerrit.wikimedia.org/r/234521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia00ab2dd68938b0520253f7017d685aa03c36592
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to