Unit Test Profiling

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# file: profiling.py #
from django.test.simple import run_tests
from django.conf import settings
try:
    import cProfile as profile
except ImportError:
    import profile

def profile_tests(*args, **kwargs):
    profile.runctx('run_tests(*args, **kwargs)',
                {'run_tests':run_tests,'args':args,'kwargs':kwargs},
                {},
                getattr(settings,'TEST_PROFILE',None)
            )

# file: settings.py #
TEST_RUNNER = 'profiling.profile_tests'
TEST_PROFILE = None

More like this

  1. Dynamic Test Loading by cronosa 4 years, 3 months ago
  2. Simple profile middleware by limodou 7 years, 1 month ago
  3. Unit Test Profiling for Django 1.3/1.4 by hoffmaje 1 year, 12 months ago
  4. Query printer coroutine by fnl 4 years, 12 months ago
  5. change settings locally in an individual test by akaihola 3 years, 8 months ago

Comments

(Forgotten your password?)