[Pkg-mozext-commits] [requestpolicy] 65/257: [tst][fix] rules.py: use `isinstance` on `Rule` comparison

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 ff8bcdd35a61e8ed11932d8db655e7756d64b78a
Author: Martin Kimmerle <dev at 256k.de>
Date:   Tue Oct 6 00:21:12 2015 +0200

    [tst][fix] rules.py: use `isinstance` on `Rule` comparison
---
 tests/marionette/rp_puppeteer/api/rules.py        | 2 ++
 tests/marionette/rp_puppeteer/tests/test_rules.py | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/tests/marionette/rp_puppeteer/api/rules.py b/tests/marionette/rp_puppeteer/api/rules.py
index b0fc135..2f241e0 100644
--- a/tests/marionette/rp_puppeteer/api/rules.py
+++ b/tests/marionette/rp_puppeteer/api/rules.py
@@ -123,6 +123,8 @@ class Rule(BaseLib):
         self.temp = temp
 
     def __eq__(self, other):
+        if not isinstance(other, Rule):
+            return False
         return (self.allow == other.allow and self.temp == other.temp and
                 self.rule_data == other.rule_data)
 
diff --git a/tests/marionette/rp_puppeteer/tests/test_rules.py b/tests/marionette/rp_puppeteer/tests/test_rules.py
index d0ea984..8271e51 100644
--- a/tests/marionette/rp_puppeteer/tests/test_rules.py
+++ b/tests/marionette/rp_puppeteer/tests/test_rules.py
@@ -177,6 +177,12 @@ class TestRule(RulesTestCase):
                                 msg=("Variant '{}' and the Baserule are "
                                      "unequal.".format(variant_name)))
 
+        # Compare with non-`Rule` instances.
+        self.assertNotEqual(self.baserule, None)
+        self.assertNotEqual(self.baserule, {})
+        self.assertNotEqual(self.baserule, [])
+        self.assertNotEqual(self.baserule, 10)
+
     def test_adding_and_removing_rule(self):
         rule = self.baserule
         self.assertEqual(self.rules.count_rules(), 0)

-- 
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