Ticket #6298: runtests-2.patch

File runtests-2.patch, 1.4 KB (added by curtis@…, 7 years ago)

updated to use settings.configure()

  • runtests.py

     
    33import os, sys, traceback
    44import unittest
    55
     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)
     11
     12import django
    613import django.contrib as contrib
    714
     15print "\nRunning tests against " + os.path.dirname(django.__file__)
     16
    817try:
    918    set
    1019except NameError:
     
    173182    if options.settings:
    174183        os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
    175184    elif "DJANGO_SETTINGS_MODULE" not in os.environ:
    176         parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
    177                       "Set it or use --settings.")
     185        # since no settings have been defined, try setting up a test environment that uses SQLite
     186        try:
     187            import sqlite3
     188            from django.conf import settings
     189            settings.configure(DATABASE_ENGINE="sqlite3",ROOT_URLCONF="/")
     190        except:
     191            parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
     192                        "Set it or use --settings.")
    178193    django_tests(int(options.verbosity), options.interactive, args)
Back to Top