Ticket #5376: testserver-addrport.patch

File testserver-addrport.patch, 3.1 KB (added by Todd O'Bryan, 17 years ago)
  • django/core/management/commands/testserver.py

    Property changes on: .
    ___________________________________________________________________
    Name: svn:ignore
       - build
    dist
    *.egg-info
    MANIFEST
    
       + build
    dist
    *.egg-info
    MANIFEST
    .settings
    .project
    .pydevproject
    
    
     
    77        make_option('--verbosity', action='store', dest='verbosity', default='1',
    88            type='choice', choices=['0', '1', '2'],
    99            help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'),
     10        make_option('--addrport', action='store', dest='addrport',
     11            type='string', default='',
     12            help='port number or ipaddr:port to run the server on'),
    1013    )
    1114    help = 'Runs a development server with data from the given fixture(s).'
    1215    args = '[fixture ...]'
     
    1922        from django.test.utils import create_test_db
    2023
    2124        verbosity = int(options.get('verbosity', 1))
     25        addrport = options.get('addrport')
    2226
    2327        # Create a test database.
    2428        db_name = create_test_db(verbosity=verbosity)
     
    3034        # a strange error -- it causes this handle() method to be called
    3135        # multiple times.
    3236        shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name
    33         call_command('runserver', shutdown_message=shutdown_message, use_reloader=False)
     37        call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False)
  • docs/django-admin.txt

     
    627627      in any way, knowing that whatever data changes you're making are only
    628628      being made to a test database.
    629629
    630 Note that this server can only run on the default port on localhost; it does
    631 not yet accept a ``host`` or ``port`` parameter.
     630Note that this server does *not* automatically detect changes to your Python
     631source code (as ``runserver`` does). It does, however, detect changes to
     632templates.
    632633
    633 Also note that it does *not* automatically detect changes to your Python source
    634 code (as ``runserver`` does). It does, however, detect changes to templates.
    635 
    636634.. _unit tests: ../testing/
    637635
     636--addrport [port number or ipaddr:port]
     637~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     638
     639Use ``--addrport`` to specify a different port, or IP address and port, from
     640the default of 127.0.0.1:8000. The argument to the ``--addrport`` option
     641follows exactly the same format and serves exactly the same function as the
     642argument to the ``runserver`` subcommand.
     643
     644Examples:
     645
     646To run the test server on port 7000 with ``fixture1`` and ``fixture2``::
     647
     648    django-admin.py testserver --addrport 7000 fixture1 fixture2
     649   
     650To run on 1.2.3.4:7000 with a `test` fixture::
     651
     652    django-admin.py testserver --addrport 1.2.3.4:7000 test
     653
    638654--verbosity
    639655~~~~~~~~~~~
    640656
Back to Top