Ticket #13873: TEST_SKIP_APP_TESTS.diff

File TEST_SKIP_APP_TESTS.diff, 4.1 KB (added by Lakin Wecker, 14 years ago)

TEST_SKIP_APP_TESTS setting

  • django/test/simple.py

     
    244244                    app = get_app(label)
    245245                    suite.addTest(build_suite(app))
    246246        else:
    247             for app in get_apps():
    248                 suite.addTest(build_suite(app))
     247            for app_name in settings.INSTALLED_APPS:
     248                if app_name not in settings.TEST_SKIP_APP_TESTS:
     249                    app = get_app(app_name.split('.')[-1])
     250                    suite.addTest(build_suite(app))
    249251
    250252        if extra_tests:
    251253            for test in extra_tests:
  • django/conf/global_settings.py

     
    515515TEST_DATABASE_CHARSET = None
    516516TEST_DATABASE_COLLATION = None
    517517
     518# A list of INSTALLED_APPs that should (by default) be skipped when running the tests.
     519TEST_SKIP_APP_TESTS = ()
     520
    518521############
    519522# FIXTURES #
    520523############
  • tests/regressiontests/skip_these_tests/tests.py

     
     1"""
     2These are tests that should never run as they are included in the TEST_SKIP_APP_TESTS
     3"""
     4
     5from django.test import TestCase
     6
     7class SkipTheseTests(TestCase):
     8
     9    def test_this_test_should_be_skipped(self):
     10        """
     11        This test should never run as the app is registered in TEST_SKIP_APP_TESTS
     12        """
     13        self.fail(
     14            "This test should never run as the app (modeltests.skip_these_tests) "\
     15            "is registered in TEST_SKIP_APP_TESTS"
     16        )
     17
  • tests/runtests.py

     
    8888    from django.conf import settings
    8989
    9090    old_installed_apps = settings.INSTALLED_APPS
     91    old_skip_app_tests = settings.TEST_SKIP_APP_TESTS
    9192    old_root_urlconf = getattr(settings, "ROOT_URLCONF", "")
    9293    old_template_dirs = settings.TEMPLATE_DIRS
    9394    old_use_i18n = settings.USE_I18N
     
    9798
    9899    # Redirect some settings for the duration of these tests.
    99100    settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
     101    settings.TEST_SKIP_APP_TESTS = ('regressiontests.skip_these_tests',)
    100102    settings.ROOT_URLCONF = 'urls'
    101103    settings.TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), TEST_TEMPLATE_DIR),)
    102104    settings.USE_I18N = True
     
    176178
    177179    # Restore the old settings.
    178180    settings.INSTALLED_APPS = old_installed_apps
     181    settings.TEST_SKIP_APP_TESTS = old_skip_app_tests
    179182    settings.ROOT_URLCONF = old_root_urlconf
    180183    settings.TEMPLATE_DIRS = old_template_dirs
    181184    settings.USE_I18N = old_use_i18n
  • docs/ref/settings.txt

     
    387387
    388388See :ref:`topics-testing`.
    389389
     390TEST_SKIP_APP_TESTS
     391~~~~~~~~~
    390392
     393Default: ``()`` (Empty tuple)
     394
     395A tuple of strings designating all applications that should be skipped
     396when running tests.  Each string should be a full Python path to a Python
     397package that contains a Django application.  Use this setting to exclude
     398any thirdparty applications that are listed in :setting:`INSTALLED_APPS`
     399that should not be tested as part of your normal workflow.  Note that
     400if you specify a set of applications as command line arguments to the test
     401command, they will not be excluded even if they are listed here.
     402
    391403.. setting:: DATABASE_ROUTERS
    392404
    393405DATABASE_ROUTERS
Back to Top