[Pkg-mozext-commits] [requestpolicy] 64/257: [tst][fix] rules.py: implement __ne__

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:19:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 2d5c4724048883990fe8fa41b18e7ca92cc7f373
Author: Martin Kimmerle <dev at 256k.de>
Date:   Tue Oct 6 00:06:35 2015 +0200

    [tst][fix] rules.py: implement __ne__
    
    To completely implement `==` and `!=` „rich comparisons“, both
    `__eq__` and `__ne__` need to be implemented.
---
 tests/marionette/rp_puppeteer/api/rules.py        | 3 +++
 tests/marionette/rp_puppeteer/tests/test_rules.py | 7 ++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tests/marionette/rp_puppeteer/api/rules.py b/tests/marionette/rp_puppeteer/api/rules.py
index 268ceff..b0fc135 100644
--- a/tests/marionette/rp_puppeteer/api/rules.py
+++ b/tests/marionette/rp_puppeteer/api/rules.py
@@ -126,6 +126,9 @@ class Rule(BaseLib):
         return (self.allow == other.allow and self.temp == other.temp and
                 self.rule_data == other.rule_data)
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __cmp__(self, other):
         # Temporary rules first.
         if self.temp != other.temp:
diff --git a/tests/marionette/rp_puppeteer/tests/test_rules.py b/tests/marionette/rp_puppeteer/tests/test_rules.py
index 9a36163..d0ea984 100644
--- a/tests/marionette/rp_puppeteer/tests/test_rules.py
+++ b/tests/marionette/rp_puppeteer/tests/test_rules.py
@@ -3,6 +3,7 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from rp_ui_harness import RequestPolicyTestCase
+from rp_puppeteer.api.rules import Rule
 from marionette import SkipTest
 
 
@@ -156,7 +157,11 @@ class TestRules(RulesTestCase):
 
 class TestRule(RulesTestCase):
 
-    def test__eq__operator(self):
+    def test_eq_and_ne_rich_comparisons(self):
+        # Test that `Rule` has both the __eq__ and the __ne__ method
+        self.assertIn("__eq__", dir(Rule))
+        self.assertIn("__ne__", dir(Rule))
+
         # Create a copy of the "baserule".
         baserule_copy = self.rules.create_rule(
             rule_data=self.baserule.rule_data,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list