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

Method test_lru_cache_weakrefable

Lib/test/test_functools.py:2108–2135  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2106 self.assertEqual(f.cache_parameters(), {'maxsize': 1000, "typed": True})
2107
2108 def test_lru_cache_weakrefable(self):
2109 @self.module.lru_cache
2110 def test_function(x):
2111 return x
2112
2113 class A:
2114 @self.module.lru_cache
2115 def test_method(self, x):
2116 return (self, x)
2117
2118 @staticmethod
2119 @self.module.lru_cache
2120 def test_staticmethod(x):
2121 return (self, x)
2122
2123 refs = [weakref.ref(test_function),
2124 weakref.ref(A.test_method),
2125 weakref.ref(A.test_staticmethod)]
2126
2127 for ref in refs:
2128 self.assertIsNotNone(ref())
2129
2130 del A
2131 del test_function
2132 gc.collect()
2133
2134 for ref in refs:
2135 self.assertIsNone(ref())
2136
2137 def test_common_signatures(self):
2138 def orig(a, /, b, c=True): ...

Callers

nothing calls this directly

Calls 3

assertIsNotNoneMethod · 0.80
collectMethod · 0.80
assertIsNoneMethod · 0.80

Tested by

no test coverage detected