@pytest.fixture(scope='session', autouse=True)
def delete_pattern():
 from django.core.cache.backends.locmem import LocMemCache
 LocMemCache.delete_pattern = (lambda x, y: 0)

@ pytest . fixture ( scope = 'session' , autouse = True ) def delete_pattern ( ) : from django . core . cache . backends . locmem import LocMemCache LocMemCache . delete_pattern = ( lambda x , y : 0 )
adds the no-op delete_pattern() method to locmemcache .