diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-07-09 13:16:26 +0000 |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-07-09 13:16:26 +0000 |
commit | ead883a366b90df45de02c527e88b5200ad04f81 (patch) | |
tree | 7cf1ff37b45c33985415eb9c73a1dbaf85270014 /Lib/test/test_fnmatch.py | |
parent | 921d30d2611c3efb5dd7081d93d02415da5b49ea (diff) | |
download | cpython-git-ead883a366b90df45de02c527e88b5200ad04f81.tar.gz |
Merged revisions 82730-82731 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
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.
........
r82731 | r.david.murray | 2010-07-09 09:14:03 -0400 (Fri, 09 Jul 2010) | 2 lines
Fix sort order mistake in Misc/ACKS.
........
Diffstat (limited to 'Lib/test/test_fnmatch.py')
-rw-r--r-- | Lib/test/test_fnmatch.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 506c67999c..f2966ad724 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -3,7 +3,7 @@ from test import support import unittest -from fnmatch import fnmatch, fnmatchcase +from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb class FnmatchTestCase(unittest.TestCase): @@ -55,6 +55,21 @@ 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) + def test_main(): support.run_unittest(FnmatchTestCase) |