noseperf.wrappers.django.patch_cursor

Here are the examples of the python api noseperf.wrappers.django.patch_cursor taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: nose-performance Source File: plugin.py
    def patch_django_interfaces(self):
        import django
        from django.conf import settings
        from noseperf.wrappers.django import DjangoTemplateWrapper, patch_cursor

        self.add_context(PatchContext('django.db.backends.BaseDatabaseWrapper.cursor', patch_cursor(self._calls)))

        self.add_context(PatchContext('django.template.Template._render', DjangoTemplateWrapper(self._calls)))

        cache_backends = set()
        if django.VERSION < (1, 3):
            backend = settings.CACHE_BACKEND.split(':', 1)[0]
            if '.' not in backend:
                backend = 'django.core.cache.backends.%s' % backend
            path = '%s.CacheClass' % backend
            cache_backends.add(path)

        else:
            for cache_config in settings.CACHES.itervalues():
                cache_backends.add(cache_config['BACKEND'])

        for path in cache_backends:
            for cmd in ('get', 'set', 'add', 'delete', 'get_many'):
                self.add_context(PatchContext('%s.%s' % (path, cmd), FunctionWrapper('cache', self._calls)))