Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_fnmatch.py

    r2 r391  
    44import unittest
    55
    6 from fnmatch import fnmatch, fnmatchcase
     6from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache
     7from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _purge
    78
    89
    910class FnmatchTestCase(unittest.TestCase):
     11
     12    def tearDown(self):
     13        _purge()
     14
    1015    def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
    1116        if should_match:
    1217            self.assertTrue(fn(filename, pattern),
    13                             "expected %r to match pattern %r"
    14                             % (filename, pattern))
     18                         "expected %r to match pattern %r"
     19                         % (filename, pattern))
    1520        else:
    1621            self.assertTrue(not fn(filename, pattern),
    17                             "expected %r not to match pattern %r"
    18                             % (filename, pattern))
     22                         "expected %r not to match pattern %r"
     23                         % (filename, pattern))
    1924
    2025    def test_fnmatch(self):
     
    5055        check('abc', 'AbC', 0, fnmatchcase)
    5156
     57    def test_cache_clearing(self):
     58        # check that caches do not grow too large
     59        # http://bugs.python.org/issue7846
     60
     61        # string pattern cache
     62        for i in range(_MAXCACHE + 1):
     63            fnmatch('foo', '?' * i)
     64
     65        self.assertLessEqual(len(_cache), _MAXCACHE)
    5266
    5367def test_main():
Note: See TracChangeset for help on using the changeset viewer.