MCPcopy Index your code
hub / github.com/RustPython/RustPython / testcontext

Method testcontext

Lib/test/test_weakset.py:374–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

372 s = WeakSet(items)
373 @contextlib.contextmanager
374 def testcontext():
375 try:
376 it = iter(s)
377 # Start iterator
378 yielded = ustr(str(next(it)))
379 # Schedule an item for removal and recreate it
380 u = ustr(str(items.pop()))
381 if yielded == u:
382 # The iterator still has a reference to the removed item,
383 # advance it (issue #20006).
384 next(it)
385 gc.collect() # just in case
386 yield u
387 finally:
388 it = None # should commit all removals
389
390 with testcontext() as u:
391 self.assertNotIn(u, s)

Callers

nothing calls this directly

Calls 5

iterFunction · 0.85
strFunction · 0.85
nextFunction · 0.85
collectMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected