diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-09-14 19:17:15 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-09-14 19:17:15 +0000 |
| commit | fe78237a220ad841d806dd9ee53961e7c1d3c7b2 (patch) | |
| tree | 0358e71714c8c23fea9301070594750c72b302bb | |
| parent | 725716b5f5de01e374c9015d02baf25029a0f3c7 (diff) | |
Fixed #5376 -- Added --addrport option to the 'testserver' command. Thanks, toddobryan
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6204 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/management/commands/testserver.py | 6 | ||||
| -rw-r--r-- | docs/django-admin.txt | 30 |
2 files changed, 30 insertions, 6 deletions
diff --git a/django/core/management/commands/testserver.py b/django/core/management/commands/testserver.py index 50a10a12bc..9b169d3d9b 100644 --- a/django/core/management/commands/testserver.py +++ b/django/core/management/commands/testserver.py @@ -7,6 +7,9 @@ class Command(BaseCommand): make_option('--verbosity', action='store', dest='verbosity', default='1', type='choice', choices=['0', '1', '2'], help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), + make_option('--addrport', action='store', dest='addrport', + type='string', default='', + help='port number or ipaddr:port to run the server on'), ) help = 'Runs a development server with data from the given fixture(s).' args = '[fixture ...]' @@ -19,6 +22,7 @@ class Command(BaseCommand): from django.test.utils import create_test_db verbosity = int(options.get('verbosity', 1)) + addrport = options.get('addrport') # Create a test database. db_name = create_test_db(verbosity=verbosity) @@ -30,4 +34,4 @@ class Command(BaseCommand): # a strange error -- it causes this handle() method to be called # multiple times. shutdown_message = '\nServer stopped.\nNote that the test database, %r, has not been deleted. You can explore it on your own.' % db_name - call_command('runserver', shutdown_message=shutdown_message, use_reloader=False) + call_command('runserver', addrport=addrport, shutdown_message=shutdown_message, use_reloader=False) diff --git a/docs/django-admin.txt b/docs/django-admin.txt index cdd31a2c48..68fcad24fe 100644 --- a/docs/django-admin.txt +++ b/docs/django-admin.txt @@ -627,14 +627,34 @@ This is useful in a number of ways: in any way, knowing that whatever data changes you're making are only being made to a test database. -Note that this server can only run on the default port on localhost; it does -not yet accept a ``host`` or ``port`` parameter. - -Also note that it does *not* automatically detect changes to your Python source -code (as ``runserver`` does). It does, however, detect changes to templates. +Note that this server does *not* automatically detect changes to your Python +source code (as ``runserver`` does). It does, however, detect changes to +templates. .. _unit tests: ../testing/ +--addrport [port number or ipaddr:port] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use ``--addrport`` to specify a different port, or IP address and port, from +the default of 127.0.0.1:8000. This value follows exactly the same format and +serves exactly the same function as the argument to the ``runserver`` subcommand. + +Examples: + +To run the test server on port 7000 with ``fixture1`` and ``fixture2``:: + + django-admin.py testserver --addrport 7000 fixture1 fixture2 + django-admin.py testserver fixture1 fixture2 --addrport 8080 + +(The above statements are equivalent. We include both of them to demonstrate +that it doesn't matter whether the options come before or after the +``testserver`` command.) + +To run on 1.2.3.4:7000 with a `test` fixture:: + + django-admin.py testserver --addrport 1.2.3.4:7000 test + --verbosity ~~~~~~~~~~~ |
