mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #25447: Copying the lru_cache() wrapper object now always works,
independedly from the type of the wrapped object (by returning the original object unchanged).
This commit is contained in:
parent
762d5ea875
commit
e4d65e3aab
3 changed files with 32 additions and 2 deletions
|
@ -1262,14 +1262,24 @@ class TestLRU:
|
|||
|
||||
def test_copy(self):
|
||||
cls = self.__class__
|
||||
for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth:
|
||||
def orig(x, y):
|
||||
return 3 * x + y
|
||||
part = self.module.partial(orig, 2)
|
||||
funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth,
|
||||
self.module.lru_cache(2)(part))
|
||||
for f in funcs:
|
||||
with self.subTest(func=f):
|
||||
f_copy = copy.copy(f)
|
||||
self.assertIs(f_copy, f)
|
||||
|
||||
def test_deepcopy(self):
|
||||
cls = self.__class__
|
||||
for f in cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth:
|
||||
def orig(x, y):
|
||||
return 3 * x + y
|
||||
part = self.module.partial(orig, 2)
|
||||
funcs = (cls.cached_func[0], cls.cached_meth, cls.cached_staticmeth,
|
||||
self.module.lru_cache(2)(part))
|
||||
for f in funcs:
|
||||
with self.subTest(func=f):
|
||||
f_copy = copy.deepcopy(f)
|
||||
self.assertIs(f_copy, f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue