Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 1 | import unittest |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 2 | from test import support |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 3 | from weakref import proxy, ref, WeakSet |
| 4 | import operator |
| 5 | import copy |
| 6 | import string |
| 7 | import os |
| 8 | from random import randrange, shuffle |
| 9 | import sys |
| 10 | import warnings |
| 11 | import collections |
| 12 | from collections import UserString as ustr |
Antoine Pitrou | c1baa60 | 2010-01-08 17:54:23 +0000 | [diff] [blame] | 13 | import gc |
| 14 | import contextlib |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 15 | |
| 16 | |
| 17 | class Foo: |
| 18 | pass |
| 19 | |
| 20 | |
| 21 | class TestWeakSet(unittest.TestCase): |
| 22 | |
| 23 | def setUp(self): |
| 24 | # need to keep references to them |
| 25 | self.items = [ustr(c) for c in ('a', 'b', 'c')] |
| 26 | self.items2 = [ustr(c) for c in ('x', 'y', 'z')] |
| 27 | self.letters = [ustr(c) for c in string.ascii_letters] |
| 28 | self.s = WeakSet(self.items) |
| 29 | self.d = dict.fromkeys(self.items) |
| 30 | self.obj = ustr('F') |
| 31 | self.fs = WeakSet([self.obj]) |
| 32 | |
| 33 | def test_methods(self): |
| 34 | weaksetmethods = dir(WeakSet) |
| 35 | for method in dir(set): |
Georg Brandl | 02c0bbb | 2008-05-18 21:04:46 +0000 | [diff] [blame] | 36 | if method == 'test_c_api' or method.startswith('_'): |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 37 | continue |
Ezio Melotti | b58e0bd | 2010-01-23 15:40:09 +0000 | [diff] [blame] | 38 | self.assertIn(method, weaksetmethods, |
Georg Brandl | 1921970 | 2008-05-18 17:10:40 +0000 | [diff] [blame] | 39 | "WeakSet missing method " + method) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 40 | |
| 41 | def test_new_or_init(self): |
| 42 | self.assertRaises(TypeError, WeakSet, [], 2) |
| 43 | |
| 44 | def test_len(self): |
| 45 | self.assertEqual(len(self.s), len(self.d)) |
| 46 | self.assertEqual(len(self.fs), 1) |
| 47 | del self.obj |
| 48 | self.assertEqual(len(self.fs), 0) |
| 49 | |
| 50 | def test_contains(self): |
| 51 | for c in self.letters: |
| 52 | self.assertEqual(c in self.s, c in self.d) |
Georg Brandl | f8de3fe | 2010-12-03 07:55:44 +0000 | [diff] [blame] | 53 | # 1 is not weakref'able, but that TypeError is caught by __contains__ |
| 54 | self.assertNotIn(1, self.s) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 55 | self.assertIn(self.obj, self.fs) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 56 | del self.obj |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 57 | self.assertNotIn(ustr('F'), self.fs) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 58 | |
| 59 | def test_union(self): |
| 60 | u = self.s.union(self.items2) |
| 61 | for c in self.letters: |
| 62 | self.assertEqual(c in u, c in self.d or c in self.items2) |
| 63 | self.assertEqual(self.s, WeakSet(self.items)) |
| 64 | self.assertEqual(type(u), WeakSet) |
| 65 | self.assertRaises(TypeError, self.s.union, [[]]) |
| 66 | for C in set, frozenset, dict.fromkeys, list, tuple: |
| 67 | x = WeakSet(self.items + self.items2) |
| 68 | c = C(self.items2) |
| 69 | self.assertEqual(self.s.union(c), x) |
| 70 | |
| 71 | def test_or(self): |
| 72 | i = self.s.union(self.items2) |
| 73 | self.assertEqual(self.s | set(self.items2), i) |
| 74 | self.assertEqual(self.s | frozenset(self.items2), i) |
| 75 | |
| 76 | def test_intersection(self): |
| 77 | i = self.s.intersection(self.items2) |
| 78 | for c in self.letters: |
| 79 | self.assertEqual(c in i, c in self.d and c in self.items2) |
| 80 | self.assertEqual(self.s, WeakSet(self.items)) |
| 81 | self.assertEqual(type(i), WeakSet) |
| 82 | for C in set, frozenset, dict.fromkeys, list, tuple: |
| 83 | x = WeakSet([]) |
| 84 | self.assertEqual(self.s.intersection(C(self.items2)), x) |
| 85 | |
| 86 | def test_isdisjoint(self): |
Benjamin Peterson | c9c0f20 | 2009-06-30 23:06:06 +0000 | [diff] [blame] | 87 | self.assertTrue(self.s.isdisjoint(WeakSet(self.items2))) |
| 88 | self.assertTrue(not self.s.isdisjoint(WeakSet(self.letters))) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 89 | |
| 90 | def test_and(self): |
| 91 | i = self.s.intersection(self.items2) |
| 92 | self.assertEqual(self.s & set(self.items2), i) |
| 93 | self.assertEqual(self.s & frozenset(self.items2), i) |
| 94 | |
| 95 | def test_difference(self): |
| 96 | i = self.s.difference(self.items2) |
| 97 | for c in self.letters: |
| 98 | self.assertEqual(c in i, c in self.d and c not in self.items2) |
| 99 | self.assertEqual(self.s, WeakSet(self.items)) |
| 100 | self.assertEqual(type(i), WeakSet) |
| 101 | self.assertRaises(TypeError, self.s.difference, [[]]) |
| 102 | |
| 103 | def test_sub(self): |
| 104 | i = self.s.difference(self.items2) |
| 105 | self.assertEqual(self.s - set(self.items2), i) |
| 106 | self.assertEqual(self.s - frozenset(self.items2), i) |
| 107 | |
| 108 | def test_symmetric_difference(self): |
| 109 | i = self.s.symmetric_difference(self.items2) |
| 110 | for c in self.letters: |
| 111 | self.assertEqual(c in i, (c in self.d) ^ (c in self.items2)) |
| 112 | self.assertEqual(self.s, WeakSet(self.items)) |
| 113 | self.assertEqual(type(i), WeakSet) |
| 114 | self.assertRaises(TypeError, self.s.symmetric_difference, [[]]) |
| 115 | |
| 116 | def test_xor(self): |
| 117 | i = self.s.symmetric_difference(self.items2) |
| 118 | self.assertEqual(self.s ^ set(self.items2), i) |
| 119 | self.assertEqual(self.s ^ frozenset(self.items2), i) |
| 120 | |
| 121 | def test_sub_and_super(self): |
| 122 | pl, ql, rl = map(lambda s: [ustr(c) for c in s], ['ab', 'abcde', 'def']) |
| 123 | p, q, r = map(WeakSet, (pl, ql, rl)) |
Benjamin Peterson | c9c0f20 | 2009-06-30 23:06:06 +0000 | [diff] [blame] | 124 | self.assertTrue(p < q) |
| 125 | self.assertTrue(p <= q) |
| 126 | self.assertTrue(q <= q) |
| 127 | self.assertTrue(q > p) |
| 128 | self.assertTrue(q >= p) |
| 129 | self.assertFalse(q < r) |
| 130 | self.assertFalse(q <= r) |
| 131 | self.assertFalse(q > r) |
| 132 | self.assertFalse(q >= r) |
| 133 | self.assertTrue(set('a').issubset('abc')) |
| 134 | self.assertTrue(set('abc').issuperset('a')) |
| 135 | self.assertFalse(set('a').issubset('cbs')) |
| 136 | self.assertFalse(set('cbs').issuperset('a')) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 137 | |
| 138 | def test_gc(self): |
| 139 | # Create a nest of cycles to exercise overall ref count check |
Robert Schuppenies | 4ad1d6f | 2009-05-17 17:32:20 +0000 | [diff] [blame] | 140 | s = WeakSet(Foo() for i in range(1000)) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 141 | for elem in s: |
| 142 | elem.cycle = s |
| 143 | elem.sub = elem |
Robert Schuppenies | 4ad1d6f | 2009-05-17 17:32:20 +0000 | [diff] [blame] | 144 | elem.set = WeakSet([elem]) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 145 | |
| 146 | def test_subclass_with_custom_hash(self): |
| 147 | # Bug #1257731 |
| 148 | class H(WeakSet): |
| 149 | def __hash__(self): |
| 150 | return int(id(self) & 0x7fffffff) |
| 151 | s=H() |
| 152 | f=set() |
| 153 | f.add(s) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 154 | self.assertIn(s, f) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 155 | f.remove(s) |
| 156 | f.add(s) |
| 157 | f.discard(s) |
| 158 | |
| 159 | def test_init(self): |
| 160 | s = WeakSet() |
| 161 | s.__init__(self.items) |
| 162 | self.assertEqual(s, self.s) |
| 163 | s.__init__(self.items2) |
| 164 | self.assertEqual(s, WeakSet(self.items2)) |
| 165 | self.assertRaises(TypeError, s.__init__, s, 2); |
| 166 | self.assertRaises(TypeError, s.__init__, 1); |
| 167 | |
| 168 | def test_constructor_identity(self): |
| 169 | s = WeakSet(self.items) |
| 170 | t = WeakSet(s) |
| 171 | self.assertNotEqual(id(s), id(t)) |
| 172 | |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 173 | def test_hash(self): |
| 174 | self.assertRaises(TypeError, hash, self.s) |
| 175 | |
| 176 | def test_clear(self): |
| 177 | self.s.clear() |
Robert Schuppenies | 4ad1d6f | 2009-05-17 17:32:20 +0000 | [diff] [blame] | 178 | self.assertEqual(self.s, WeakSet([])) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 179 | self.assertEqual(len(self.s), 0) |
| 180 | |
| 181 | def test_copy(self): |
| 182 | dup = self.s.copy() |
| 183 | self.assertEqual(self.s, dup) |
| 184 | self.assertNotEqual(id(self.s), id(dup)) |
| 185 | |
| 186 | def test_add(self): |
| 187 | x = ustr('Q') |
| 188 | self.s.add(x) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 189 | self.assertIn(x, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 190 | dup = self.s.copy() |
| 191 | self.s.add(x) |
| 192 | self.assertEqual(self.s, dup) |
| 193 | self.assertRaises(TypeError, self.s.add, []) |
| 194 | self.fs.add(Foo()) |
Benjamin Peterson | c9c0f20 | 2009-06-30 23:06:06 +0000 | [diff] [blame] | 195 | self.assertTrue(len(self.fs) == 1) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 196 | self.fs.add(self.obj) |
Benjamin Peterson | c9c0f20 | 2009-06-30 23:06:06 +0000 | [diff] [blame] | 197 | self.assertTrue(len(self.fs) == 1) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 198 | |
| 199 | def test_remove(self): |
| 200 | x = ustr('a') |
| 201 | self.s.remove(x) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 202 | self.assertNotIn(x, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 203 | self.assertRaises(KeyError, self.s.remove, x) |
| 204 | self.assertRaises(TypeError, self.s.remove, []) |
| 205 | |
| 206 | def test_discard(self): |
| 207 | a, q = ustr('a'), ustr('Q') |
| 208 | self.s.discard(a) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 209 | self.assertNotIn(a, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 210 | self.s.discard(q) |
| 211 | self.assertRaises(TypeError, self.s.discard, []) |
| 212 | |
| 213 | def test_pop(self): |
| 214 | for i in range(len(self.s)): |
| 215 | elem = self.s.pop() |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 216 | self.assertNotIn(elem, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 217 | self.assertRaises(KeyError, self.s.pop) |
| 218 | |
| 219 | def test_update(self): |
| 220 | retval = self.s.update(self.items2) |
| 221 | self.assertEqual(retval, None) |
| 222 | for c in (self.items + self.items2): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 223 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 224 | self.assertRaises(TypeError, self.s.update, [[]]) |
| 225 | |
| 226 | def test_update_set(self): |
| 227 | self.s.update(set(self.items2)) |
| 228 | for c in (self.items + self.items2): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 229 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 230 | |
| 231 | def test_ior(self): |
| 232 | self.s |= set(self.items2) |
| 233 | for c in (self.items + self.items2): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 234 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 235 | |
| 236 | def test_intersection_update(self): |
| 237 | retval = self.s.intersection_update(self.items2) |
| 238 | self.assertEqual(retval, None) |
| 239 | for c in (self.items + self.items2): |
| 240 | if c in self.items2 and c in self.items: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 241 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 242 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 243 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 244 | self.assertRaises(TypeError, self.s.intersection_update, [[]]) |
| 245 | |
| 246 | def test_iand(self): |
| 247 | self.s &= set(self.items2) |
| 248 | for c in (self.items + self.items2): |
| 249 | if c in self.items2 and c in self.items: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 250 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 251 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 252 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 253 | |
| 254 | def test_difference_update(self): |
| 255 | retval = self.s.difference_update(self.items2) |
| 256 | self.assertEqual(retval, None) |
| 257 | for c in (self.items + self.items2): |
| 258 | if c in self.items and c not in self.items2: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 259 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 260 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 261 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 262 | self.assertRaises(TypeError, self.s.difference_update, [[]]) |
| 263 | self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) |
| 264 | |
| 265 | def test_isub(self): |
| 266 | self.s -= set(self.items2) |
| 267 | for c in (self.items + self.items2): |
| 268 | if c in self.items and c not in self.items2: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 269 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 270 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 271 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 272 | |
| 273 | def test_symmetric_difference_update(self): |
| 274 | retval = self.s.symmetric_difference_update(self.items2) |
| 275 | self.assertEqual(retval, None) |
| 276 | for c in (self.items + self.items2): |
| 277 | if (c in self.items) ^ (c in self.items2): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 278 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 279 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 280 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 281 | self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]]) |
| 282 | |
| 283 | def test_ixor(self): |
| 284 | self.s ^= set(self.items2) |
| 285 | for c in (self.items + self.items2): |
| 286 | if (c in self.items) ^ (c in self.items2): |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 287 | self.assertIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 288 | else: |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 289 | self.assertNotIn(c, self.s) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 290 | |
| 291 | def test_inplace_on_self(self): |
| 292 | t = self.s.copy() |
| 293 | t |= t |
| 294 | self.assertEqual(t, self.s) |
| 295 | t &= t |
| 296 | self.assertEqual(t, self.s) |
| 297 | t -= t |
| 298 | self.assertEqual(t, WeakSet()) |
| 299 | t = self.s.copy() |
| 300 | t ^= t |
| 301 | self.assertEqual(t, WeakSet()) |
| 302 | |
Robert Schuppenies | 4ad1d6f | 2009-05-17 17:32:20 +0000 | [diff] [blame] | 303 | def test_eq(self): |
| 304 | # issue 5964 |
| 305 | self.assertTrue(self.s == self.s) |
| 306 | self.assertTrue(self.s == WeakSet(self.items)) |
| 307 | self.assertFalse(self.s == set(self.items)) |
| 308 | self.assertFalse(self.s == list(self.items)) |
| 309 | self.assertFalse(self.s == tuple(self.items)) |
| 310 | self.assertFalse(self.s == WeakSet([Foo])) |
| 311 | self.assertFalse(self.s == 1) |
| 312 | |
Antoine Pitrou | c1baa60 | 2010-01-08 17:54:23 +0000 | [diff] [blame] | 313 | def test_weak_destroy_while_iterating(self): |
| 314 | # Issue #7105: iterators shouldn't crash when a key is implicitly removed |
| 315 | # Create new items to be sure no-one else holds a reference |
| 316 | items = [ustr(c) for c in ('a', 'b', 'c')] |
| 317 | s = WeakSet(items) |
| 318 | it = iter(s) |
| 319 | next(it) # Trigger internal iteration |
| 320 | # Destroy an item |
| 321 | del items[-1] |
| 322 | gc.collect() # just in case |
| 323 | # We have removed either the first consumed items, or another one |
| 324 | self.assertIn(len(list(it)), [len(items), len(items) - 1]) |
| 325 | del it |
| 326 | # The removal has been committed |
| 327 | self.assertEqual(len(s), len(items)) |
| 328 | |
| 329 | def test_weak_destroy_and_mutate_while_iterating(self): |
| 330 | # Issue #7105: iterators shouldn't crash when a key is implicitly removed |
| 331 | items = [ustr(c) for c in string.ascii_letters] |
| 332 | s = WeakSet(items) |
| 333 | @contextlib.contextmanager |
| 334 | def testcontext(): |
| 335 | try: |
| 336 | it = iter(s) |
| 337 | next(it) |
| 338 | # Schedule an item for removal and recreate it |
| 339 | u = ustr(str(items.pop())) |
| 340 | gc.collect() # just in case |
| 341 | yield u |
| 342 | finally: |
| 343 | it = None # should commit all removals |
| 344 | |
| 345 | with testcontext() as u: |
Ezio Melotti | b58e0bd | 2010-01-23 15:40:09 +0000 | [diff] [blame] | 346 | self.assertNotIn(u, s) |
Antoine Pitrou | c1baa60 | 2010-01-08 17:54:23 +0000 | [diff] [blame] | 347 | with testcontext() as u: |
| 348 | self.assertRaises(KeyError, s.remove, u) |
Ezio Melotti | b58e0bd | 2010-01-23 15:40:09 +0000 | [diff] [blame] | 349 | self.assertNotIn(u, s) |
Antoine Pitrou | c1baa60 | 2010-01-08 17:54:23 +0000 | [diff] [blame] | 350 | with testcontext() as u: |
| 351 | s.add(u) |
Benjamin Peterson | 577473f | 2010-01-19 00:09:57 +0000 | [diff] [blame] | 352 | self.assertIn(u, s) |
Antoine Pitrou | c1baa60 | 2010-01-08 17:54:23 +0000 | [diff] [blame] | 353 | t = s.copy() |
| 354 | with testcontext() as u: |
| 355 | s.update(t) |
| 356 | self.assertEqual(len(s), len(t)) |
| 357 | with testcontext() as u: |
| 358 | s.clear() |
| 359 | self.assertEqual(len(s), 0) |
| 360 | |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 361 | |
| 362 | def test_main(verbose=None): |
Benjamin Peterson | ee8712c | 2008-05-20 21:35:26 +0000 | [diff] [blame] | 363 | support.run_unittest(TestWeakSet) |
Georg Brandl | 9dba5d9 | 2008-05-18 16:27:29 +0000 | [diff] [blame] | 364 | |
| 365 | if __name__ == "__main__": |
| 366 | test_main(verbose=True) |