diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-07-09 13:16:00 +0000 |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-07-09 13:16:00 +0000 |
commit | abd4553fd46c7385537508f420e83c1793db3cad (patch) | |
tree | 8da7ee2e3a7cac811e6baa89e06ceba276b5051c /Lib/test/test_fnmatch.py | |
parent | 0e6771fd30c7025a09be9e1964ff3b9f9e9d60ec (diff) | |
download | cpython-git-abd4553fd46c7385537508f420e83c1793db3cad.tar.gz |
Merged revisions 82730 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
'merge' in the sense that this is the same fix by the same author.
........
r82730 | r.david.murray | 2010-07-09 08:23:21 -0400 (Fri, 09 Jul 2010) | 4 lines
7846: limit fnmatch pattern cache to _MAXCACHE=100 entries.
Patch by Andrew Clegg.
........
Diffstat (limited to 'Lib/test/test_fnmatch.py')
-rw-r--r-- | Lib/test/test_fnmatch.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 6dca85f5ab..7f0d51d513 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -3,7 +3,7 @@ from test import test_support import unittest -from fnmatch import fnmatch, fnmatchcase +from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache class FnmatchTestCase(unittest.TestCase): @@ -49,6 +49,15 @@ class FnmatchTestCase(unittest.TestCase): check('AbC', 'abc', 0, fnmatchcase) check('abc', 'AbC', 0, fnmatchcase) + 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) def test_main(): test_support.run_unittest(FnmatchTestCase) |