summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_functools.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-06-08 09:44:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-06-08 09:44:18 (GMT)
commit391af751f2a19476cfaa53ddc35fd53aaa582e9c (patch)
tree87bcb1e970760de97b497d41bf10cf2422f63bef /Lib/test/test_functools.py
parente7070f09bcbc4aa960216d099beff4431744a7e2 (diff)
downloadcpython-391af751f2a19476cfaa53ddc35fd53aaa582e9c.zip
cpython-391af751f2a19476cfaa53ddc35fd53aaa582e9c.tar.gz
cpython-391af751f2a19476cfaa53ddc35fd53aaa582e9c.tar.bz2
Issue #14373: Other attempt to fix threaded test for lru_cache().
Diffstat (limited to 'Lib/test/test_functools.py')
-rw-r--r--Lib/test/test_functools.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 569bdcf..ac211c4 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1110,10 +1110,10 @@ class TestLRU:
self.assertEqual(currsize, 0)
start = threading.Event()
- def full(f, *args):
+ def full(k):
start.wait(10)
for _ in range(m):
- f(*args)
+ self.assertEqual(f(k, 0), orig(k, 0))
def clear():
start.wait(10)
@@ -1124,19 +1124,24 @@ class TestLRU:
sys.setswitchinterval(1e-6)
try:
# create n threads in order to fill cache
- threads = [threading.Thread(target=full, args=[f, k, k])
+ threads = [threading.Thread(target=full, args=[k])
for k in range(n)]
with support.start_threads(threads):
start.set()
hits, misses, maxsize, currsize = f.cache_info()
- self.assertLessEqual(misses, n)
- self.assertEqual(hits, m*n - misses)
+ if self.module is py_functools:
+ # XXX: Why can be not equal?
+ self.assertLessEqual(misses, n)
+ self.assertLessEqual(hits, m*n - misses)
+ else:
+ self.assertEqual(misses, n)
+ self.assertEqual(hits, m*n - misses)
self.assertEqual(currsize, n)
# create n threads in order to fill cache and 1 to clear it
threads = [threading.Thread(target=clear)]
- threads += [threading.Thread(target=full, args=[f, k, k])
+ threads += [threading.Thread(target=full, args=[k])
for k in range(n)]
start.clear()
with support.start_threads(threads):