mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Also temporarily revert r83871, to fix compilation on buildbots
This commit is contained in:
parent
c7eaede21e
commit
f14c263280
3 changed files with 60 additions and 14 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue