Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372794 )

Change subject: [IMPR] Enable comparinf LogEntry instances
......................................................................

[IMPR] Enable comparinf LogEntry instances

Bug: T173664
Change-Id: I372dfd4ff779a919d8fa4bb9bcd156221ffeee37
---
M pywikibot/logentries.py
M tests/logentry_tests.py
2 files changed, 14 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/94/372794/1

diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 26dd3cf..14953a0 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -59,6 +59,14 @@
         """Return the id as the hash."""
         return self.logid()
 
+    def __eq__(self, other):
+        """Compare LogEntry instances."""
+        if not isinstance(other, LogEntry):
+            raise TypeError("'{0}' cannot be compared with '{1}'"
+                            .format(self.__class__.__name__,
+                                    other.__class__.__name__))
+        return self.data == other.data and self.site == other.site
+
     @property
     def _params(self):
         """
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index 8f9128d..06ead91 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -224,6 +224,12 @@
         logentry = self._get_logentry('thanks')
         self.assertIsInstance(logentry.page(), pywikibot.User)
 
+    def test_equality(self):
+        site = self.get_site('dewp')
+        le1 = next(iter(site.logevents(reverse=True, total=1)))
+        le2 = next(iter(site.logevents(reverse=True, total=1)))
+        self.assertEqual(le1, le2)
+
 
 class TestDeprecatedMethods(TestLogentriesBase, DeprecationTestCase):
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I372dfd4ff779a919d8fa4bb9bcd156221ffeee37
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to