Ticket #6298: 6298.diff

File 6298.diff, 1.9 KB (added by Rob Hudson, 15 years ago)

Updated patch after multidb

  • tests/runtests.py

    diff --git a/tests/runtests.py b/tests/runtests.py
    index f2ea5f1..978281b 100755
    a b  
    33import os, sys, traceback
    44import unittest
    55
    6 import django.contrib as contrib
     6# tests should use the same version (as has been checked out)
     7if sys.argv:
     8    script_path = os.path.dirname(sys.argv[0])
     9    django_path = os.path.abspath(os.path.join(script_path, ".."))
     10    sys.path.insert(1, django_path)
    711
    8 try:
    9     set
    10 except NameError:
    11     from sets import Set as set     # For Python 2.3
     12import django
     13import django.contrib as contrib
    1214
     15print "\nRunning tests against " + os.path.dirname(django.__file__)
    1316
    1417CONTRIB_DIR_NAME = 'django.contrib'
    1518MODEL_TESTS_DIR_NAME = 'modeltests'
    if __name__ == "__main__":  
    190193    if options.settings:
    191194        os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
    192195    elif "DJANGO_SETTINGS_MODULE" not in os.environ:
    193         parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
    194                       "Set it or use --settings.")
     196        # since no settings have been defined, set up a test env using SQLite
     197        try:
     198            import sqlite3
     199            from django.conf import settings
     200            settings.configure(**{
     201                'DATABASES': {
     202                    'default': {
     203                        'ENGINE': 'django.db.backends.sqlite3'
     204                    },
     205                    'other': {
     206                        'ENGINE': 'django.db.backends.sqlite3',
     207                        'TEST_NAME': 'other_db'
     208                    }
     209                },
     210                'ROOT_URLCONF': '/',
     211            })
     212        except ImportError:
     213            parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
     214                          "Set it or use --settings.")
    195215    django_tests(int(options.verbosity), options.interactive, options.failfast, args)
Back to Top