#10360: catch TypeError in WeakSet.__contains__, just like WeakKeyDictionary does.

This commit is contained in:
Georg Brandl 2010-12-03 07:55:44 +00:00
parent 3b9406b08a
commit f8de3fea12
3 changed files with 10 additions and 2 deletions

View file

@ -50,7 +50,8 @@ class TestWeakSet(unittest.TestCase):
def test_contains(self):
for c in self.letters:
self.assertEqual(c in self.s, c in self.d)
self.assertRaises(TypeError, self.s.__contains__, [[]])
# 1 is not weakref'able, but that TypeError is caught by __contains__
self.assertNotIn(1, self.s)
self.assertIn(self.obj, self.fs)
del self.obj
self.assertNotIn(ustr('F'), self.fs)