(self)
| 1981 | |
| 1982 | @support.cpython_only |
| 1983 | def test_weak_valued_consistency(self): |
| 1984 | # A single-threaded, deterministic repro for issue #28427: old keys |
| 1985 | # should not remove new values from WeakValueDictionary. This relies on |
| 1986 | # an implementation detail of CPython's WeakValueDictionary (its |
| 1987 | # underlying dictionary of KeyedRefs) to reproduce the issue. |
| 1988 | d = weakref.WeakValueDictionary() |
| 1989 | with support.disable_gc(): |
| 1990 | d[10] = RefCycle() |
| 1991 | # Keep the KeyedRef alive after it's replaced so that GC will invoke |
| 1992 | # the callback. |
| 1993 | wr = d.data[10] |
| 1994 | # Replace the value with something that isn't cyclic garbage |
| 1995 | o = RefCycle() |
| 1996 | d[10] = o |
| 1997 | # Trigger GC, which will invoke the callback for `wr` |
| 1998 | gc.collect() |
| 1999 | self.assertEqual(len(d), 1) |
| 2000 | |
| 2001 | def check_threaded_weak_dict_copy(self, type_, deepcopy): |
| 2002 | # `type_` should be either WeakKeyDictionary or WeakValueDictionary. |
nothing calls this directly
no test coverage detected