summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_weakset.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-03-04 19:47:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-03-04 19:47:05 (GMT)
commit9c47ac05d13971d1e6ee2d74afad8d1b57e5b2ac (patch)
treea023e3782182c4b7578876c7a95a3d144e04cf4d /Lib/test/test_weakset.py
parentde89d4b09758a1c94dd97be554c967d52759228a (diff)
downloadcpython-9c47ac05d13971d1e6ee2d74afad8d1b57e5b2ac.zip
cpython-9c47ac05d13971d1e6ee2d74afad8d1b57e5b2ac.tar.gz
cpython-9c47ac05d13971d1e6ee2d74afad8d1b57e5b2ac.tar.bz2
Fix some set algebra methods of WeakSet objects.
Diffstat (limited to 'Lib/test/test_weakset.py')
-rw-r--r--Lib/test/test_weakset.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index 35db7a6..3c71f62 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -71,6 +71,11 @@ class TestWeakSet(unittest.TestCase):
x = WeakSet(self.items + self.items2)
c = C(self.items2)
self.assertEqual(self.s.union(c), x)
+ del c
+ self.assertEqual(len(u), len(self.items) + len(self.items2))
+ self.items2.pop()
+ gc.collect()
+ self.assertEqual(len(u), len(self.items) + len(self.items2))
def test_or(self):
i = self.s.union(self.items2)
@@ -78,14 +83,19 @@ class TestWeakSet(unittest.TestCase):
self.assertEqual(self.s | frozenset(self.items2), i)
def test_intersection(self):
- i = self.s.intersection(self.items2)
+ s = WeakSet(self.letters)
+ i = s.intersection(self.items2)
for c in self.letters:
- self.assertEqual(c in i, c in self.d and c in self.items2)
- self.assertEqual(self.s, WeakSet(self.items))
+ self.assertEqual(c in i, c in self.items2 and c in self.letters)
+ self.assertEqual(s, WeakSet(self.letters))
self.assertEqual(type(i), WeakSet)
for C in set, frozenset, dict.fromkeys, list, tuple:
x = WeakSet([])
- self.assertEqual(self.s.intersection(C(self.items2)), x)
+ self.assertEqual(i.intersection(C(self.items)), x)
+ self.assertEqual(len(i), len(self.items2))
+ self.items2.pop()
+ gc.collect()
+ self.assertEqual(len(i), len(self.items2))
def test_isdisjoint(self):
self.assertTrue(self.s.isdisjoint(WeakSet(self.items2)))
@@ -116,6 +126,10 @@ class TestWeakSet(unittest.TestCase):
self.assertEqual(self.s, WeakSet(self.items))
self.assertEqual(type(i), WeakSet)
self.assertRaises(TypeError, self.s.symmetric_difference, [[]])
+ self.assertEqual(len(i), len(self.items) + len(self.items2))
+ self.items2.pop()
+ gc.collect()
+ self.assertEqual(len(i), len(self.items) + len(self.items2))
def test_xor(self):
i = self.s.symmetric_difference(self.items2)