summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-09 12:47:33 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-09 12:47:33 (GMT)
commitf14c2632806ec19b0d58c2c1f721c6a31b535209 (patch)
treea8a42d4b4b1c6607efb0b0365dc7046674059cc0 /Lib/test
parentc7eaede21ecb5259f2bd9e160a89b82d19cfb19b (diff)
downloadcpython-f14c2632806ec19b0d58c2c1f721c6a31b535209.zip
cpython-f14c2632806ec19b0d58c2c1f721c6a31b535209.tar.gz
cpython-f14c2632806ec19b0d58c2c1f721c6a31b535209.tar.bz2
Also temporarily revert r83871, to fix compilation on buildbots
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_fnmatch.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index 482835d..a93558c 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -3,10 +3,15 @@
from test import support
import unittest
-from fnmatch import fnmatch, fnmatchcase, translate, filter
+from fnmatch import (fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb, purge,
+ 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),
@@ -60,6 +65,22 @@ 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):