Commits

Lucian Brănescu-Mihăilă committed 57a4cab Draft

Check type for set operations.

Comments (0)

Files changed (2)

     def __len__(self):
         return r.scard(self.name)
 
+    def _assert_is_set(self, other):
+        if not isinstance(other, Set):
+            raise TypeError("Expected mapredis.Set, got: " + type(other))
+
     def union(self, other):
+        self._assert_is_set(other)
+
         return r.sunion(self.name, other.name)
 
     def intersect(self, other):
+        self._assert_is_set(other)
+
         return r.sinter(self.name, other.name)
 
     def subtract(self, other):
+        self._assert_is_set(other)
+
         return r.sdiff(self.name, other.name)
 
     def pop(self):
 from data import List
 
+
 def test_list():
     td = ['a', 'b', 'c', 'd']
 
     a.clear()
     a.extend(td)
 
-    assert a[:] == td
+    assert a[:] == td