summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2010-08-09 02:07:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2010-08-09 02:07:15 (GMT)
commit5b0c1e07ca169feced6d6458f80c2b9ccc6227e0 (patch)
tree17ba65edefe013fcaf3edf8138dc6f38023445ca /Lib/test
parent44c6c155d6cc0d218decd250d84a238196be8daa (diff)
downloadcpython-5b0c1e07ca169feced6d6458f80c2b9ccc6227e0.zip
cpython-5b0c1e07ca169feced6d6458f80c2b9ccc6227e0.tar.gz
cpython-5b0c1e07ca169feced6d6458f80c2b9ccc6227e0.tar.bz2
Issue 7846: fnmatch cache can grow without bound
Updated to solution to use the functools.lru_cache(). Restores the API so that purge() is not needed (because the cache never gets big).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_fnmatch.py23
1 files changed, 1 insertions, 22 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index a93558c..482835d 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -3,15 +3,10 @@
from test import support
import unittest
-from fnmatch import (fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb, purge,
- translate, filter)
-
+from fnmatch import fnmatch, fnmatchcase, translate, filter
class FnmatchTestCase(unittest.TestCase):
- def tearDown(self):
- purge()
-
def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
if should_match:
self.assertTrue(fn(filename, pattern),
@@ -65,22 +60,6 @@ class FnmatchTestCase(unittest.TestCase):
self.check_match(b'test\xff', b'te*\xff')
self.check_match(b'foo\nbar', b'foo*')
- def test_cache_clearing(self):
- # check that caches do not grow too large
- # http://bugs.python.org/issue7846
-
- # string pattern cache
- for i in range(_MAXCACHE + 1):
- fnmatch('foo', '?' * i)
-
- self.assertLessEqual(len(_cache), _MAXCACHE)
-
- # bytes pattern cache
- for i in range(_MAXCACHE + 1):
- fnmatch(b'foo', b'?' * i)
- self.assertLessEqual(len(_cacheb), _MAXCACHE)
-
-
class TranslateTestCase(unittest.TestCase):
def test_translate(self):