This allows you to exclude certain apps when doing standard tests (manage.py test) by default. You set the settings/local_settings variable EXCLUDE_APPS and it will exclude those apps (like django, registration, south... etc). This makes running tests much faster and you don't have to wait for a bunch of tests you don't care about (per say).
You can override it by adding the app to the command line still. So if 'south' is in the excluded apps you can still run:
'python manage.py test south'
and it will run the south tests.
You will also need to tell django to use this as the test runner: TEST_RUNNER = 'testing.simple.AdvancedTestSuiteRunner'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
from django.test.simple import DjangoTestSuiteRunner #@UnresolvedImport import logging from django.conf import settings EXCLUDED_APPS = getattr(settings, 'TEST_EXCLUDE', ) class AdvancedTestSuiteRunner(DjangoTestSuiteRunner): def __init__(self, *args, **kwargs): from django.conf import settings settings.TESTING = True south_log = logging.getLogger("south") south_log.setLevel(logging.WARNING) super(AdvancedTestSuiteRunner, self).__init__(*args, **kwargs) def build_suite(self, *args, **kwargs): suite = super(AdvancedTestSuiteRunner, self).build_suite(*args, **kwargs) if not args and not getattr(settings, 'RUN_ALL_TESTS', False): tests =  for case in suite: pkg = case.__class__.__module__.split('.') if pkg not in EXCLUDED_APPS: tests.append(case) suite._tests = tests return suite
More like this
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 week ago
- Help text hyperlinks by sa2812 1 month ago
- Stuff by NixonDash 3 months, 1 week ago
- Add custom fields to the built-in Group model by jmoppel 5 months, 1 week ago
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 8 months, 3 weeks ago
So to install:
Place this in an app (I put it in a testing app in a file named simple.py)
Add TEST_RUNNER="testing.simple.AdvancedTestSuiteRunner" to settings
Add EXCLUDE_APPS = ('django', 'app2', app3')
Just what I needed - thanks.
(One brief note, the settings for settings.py is TEST_EXCLUDE rather than EXCLUDE_APPS incase anyone else misses that).
Please login first before commenting.