this might be better as an exception but
it's not critical either way. [ticket:2325]
+ - [feature] IdentitySet supports the - operator
+ as the same as difference(), handy when dealing
+ with Session.dirty etc. [ticket:2301]
+
- sql
- [bug] related to [ticket:2316], made some
adjustments to the change from [ticket:2261]
def clear(self):
self._members.clear()
+ def __sub__(self, other):
+ return self.difference(other)
+
def __cmp__(self, other):
raise TypeError('cannot compare sets using cmp()')
ids.add(data[i])
self.assert_eq(ids, data)
+ def test_dunder_sub(self):
+ IdentitySet = util.IdentitySet
+ o1, o2, o3 = object(), object(), object()
+ ids1 = IdentitySet([o1])
+ ids2 = IdentitySet([o1, o2, o3])
+ eq_(
+ ids2 - ids1,
+ IdentitySet([o2, o3])
+ )
+
+ ids2 -= ids1
+ eq_(ids2, IdentitySet([o2, o3]))
+
def test_basic_sanity(self):
IdentitySet = util.IdentitySet