summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fnmatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_fnmatch.py')
-rw-r--r--Lib/test/test_fnmatch.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index 6dca85f..7f0d51d 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)