summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sets.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2005-08-13 02:28:54 (GMT)
committerRaymond Hettinger <python@rcn.com>2005-08-13 02:28:54 (GMT)
commitab294199b772e47dd86ca665dbc1080715b844d2 (patch)
tree355e719f2cbc756be0d9c8a2943a9056cc304a77 /Lib/test/test_sets.py
parent787b4c5fea8476a1146918f90a6da7f63d7aa31c (diff)
downloadcpython-ab294199b772e47dd86ca665dbc1080715b844d2.zip
cpython-ab294199b772e47dd86ca665dbc1080715b844d2.tar.gz
cpython-ab294199b772e47dd86ca665dbc1080715b844d2.tar.bz2
Teach set modules to correctly compute s-=s and s^=s as the empty set.
Diffstat (limited to 'Lib/test/test_sets.py')
-rw-r--r--Lib/test/test_sets.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
index c5a48b1..ff834e0 100644
--- a/Lib/test/test_sets.py
+++ b/Lib/test/test_sets.py
@@ -243,6 +243,19 @@ class TestBinaryOps(unittest.TestCase):
self.assertRaises(TypeError, cmp, a, 12)
self.assertRaises(TypeError, cmp, "abc", a)
+ def test_inplace_on_self(self):
+ t = self.set.copy()
+ t |= t
+ self.assertEqual(t, self.set)
+ t &= t
+ self.assertEqual(t, self.set)
+ t -= t
+ self.assertEqual(len(t), 0)
+ t = self.set.copy()
+ t ^= t
+ self.assertEqual(len(t), 0)
+
+
#==============================================================================
class TestUpdateOps(unittest.TestCase):