Ticket #2879: test-server-support.patch

File test-server-support.patch, 1.9 KB (added by Almad <bugs@…>, 17 years ago)

All patches in one, with reverted utils.py

  • django/core/management.py

     
    11581158        sys.stderr.write(s.read())
    11591159        sys.exit(1)
    11601160
     1161def runtestserver(addr, port, use_reloader=False, admin_media_dir=''):
     1162    "Starts a lightweight Web server for testing."
     1163    from django.test.utils import setup_test_environment, teardown_test_environment
     1164    from django.test.utils import create_test_db, destroy_test_db
     1165    from django.conf import settings
     1166
     1167    setup_test_environment()
     1168    old_name = settings.DATABASE_NAME
     1169    create_test_db()
     1170
     1171    # Install the 'testdata' fixture, using format discovery
     1172    load_data(['test_data'], verbosity=True)
     1173
     1174    try:
     1175        use_reloader = False # Must always be False !
     1176        runserver(addr, port, use_reloader, admin_media_dir)
     1177    except SystemExit:
     1178        destroy_test_db(old_name)
     1179        teardown_test_environment()
     1180        raise
     1181
     1182    destroy_test_db(old_name)
     1183    teardown_test_environment()
     1184runtestserver.args = '[--adminmedia=ADMIN_MEDIA_PATH] [optional port number, or ipaddr:port]'
     1185
    11611186def runserver(addr, port, use_reloader=True, admin_media_dir=''):
    11621187    "Starts a lightweight Web server for development."
    11631188    from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
     
    14681493    'reset': reset,
    14691494    'runfcgi': runfcgi,
    14701495    'runserver': runserver,
     1496    'runtestserver': runtestserver,
    14711497    'shell': run_shell,
    14721498    'sql': get_sql_create,
    14731499    'sqlall': get_sql_all,
     
    16031629        except IndexError:
    16041630            parser.print_usage_and_exit()
    16051631        action_mapping[action](name, os.getcwd())
    1606     elif action == 'runserver':
     1632    elif action in ('runserver', 'runtestserver'):
    16071633        if len(args) < 2:
    16081634            addr = ''
    16091635            port = '8000'
Back to Top