<_sre.SRE_Match object at 0x...>
+.. function:: purge()
+
+ Clear the internal pattern cache.
+
+ .. versionadded:: 3.2
+
+
.. seealso::
Module :mod:`glob`
import re
-__all__ = ["filter", "fnmatch","fnmatchcase","translate"]
+__all__ = ["filter", "fnmatch", "fnmatchcase", "purge", "translate"]
_cache = {} # Maps text patterns to compiled regexen.
_cacheb = {} # Ditto for bytes patterns.
_MAXCACHE = 100 # Maximum size of caches
+def purge():
+ """Clear the pattern cache"""
+ _cache.clear()
+ _cacheb.clear()
+
def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
from test import support
import unittest
-from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb
+from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _cacheb, purge
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),