mirror of
https://github.com/django/django.git
synced 2024-12-24 10:05:46 +00:00
Fixed #10791 -- The GeoDjango test runner now respects the --noinput
command-line option, thanks to seanl for ticket & patch; replaced docstring with URL to latest documentation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10601 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5a57a7f006
commit
aeaba06bf4
@ -115,45 +115,10 @@ def run_gis_tests(test_labels, **kwargs):
|
||||
|
||||
def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[], suite=None):
|
||||
"""
|
||||
This module allows users to run tests for GIS apps that require the creation
|
||||
of a spatial database. Currently, this is only required for PostgreSQL as
|
||||
PostGIS needs extra overhead in test database creation.
|
||||
|
||||
In order to create a PostGIS database, the DATABASE_USER (or
|
||||
TEST_DATABASE_USER, if defined) will require superuser priviliges.
|
||||
|
||||
To accomplish this outside the `postgres` user, you have a few options:
|
||||
(A) Make your user a super user:
|
||||
This may be done at the time the user is created, for example:
|
||||
$ createuser --superuser <user_name>
|
||||
|
||||
Or you may alter the user's role from the SQL shell (assuming this
|
||||
is done from an existing superuser role):
|
||||
postgres# ALTER ROLE <user_name> SUPERUSER;
|
||||
|
||||
(B) Create your own PostgreSQL database as a local user:
|
||||
1. Initialize database: `initdb -D /path/to/user/db`
|
||||
2. If there's already a Postgres instance on the machine, it will need
|
||||
to use a different TCP port than 5432. Edit postgresql.conf (in
|
||||
/path/to/user/db) to change the database port (e.g. `port = 5433`).
|
||||
3. Start this database `pg_ctl -D /path/to/user/db start`
|
||||
|
||||
(C) On Windows platforms the pgAdmin III utility may also be used as
|
||||
a simple way to add superuser privileges to your database user.
|
||||
|
||||
The TEST_RUNNER needs to be set in your settings like so:
|
||||
|
||||
TEST_RUNNER='django.contrib.gis.tests.run_tests'
|
||||
|
||||
Note: This test runner assumes that the PostGIS SQL files ('lwpostgis.sql'
|
||||
and 'spatial_ref_sys.sql') are installed in the directory specified by
|
||||
`pg_config --sharedir` (and defaults to /usr/local/share if that fails).
|
||||
This behavior is overridden if POSTGIS_SQL_PATH is set in your settings.
|
||||
|
||||
Windows users should set POSTGIS_SQL_PATH manually because the output
|
||||
of `pg_config` uses paths like 'C:/PROGRA~1/POSTGR~1/..'.
|
||||
|
||||
Finally, the tests may be run by invoking `./manage.py test`.
|
||||
Set `TEST_RUNNER` in your settings with this routine in order to
|
||||
scaffold test spatial databases correctly for your GeoDjango models.
|
||||
For more documentation, please consult the following URL:
|
||||
http://geodjango.org/docs/testing.html.
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.db import connection
|
||||
@ -171,7 +136,7 @@ def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[], suite=
|
||||
old_name = settings.DATABASE_NAME
|
||||
|
||||
# Creating the test spatial database.
|
||||
create_test_spatial_db(verbosity=verbosity)
|
||||
create_test_spatial_db(verbosity=verbosity, autoclobber=not interactive)
|
||||
|
||||
# The suite may be passed in manually, e.g., when we run the GeoDjango test,
|
||||
# we want to build it and pass it in due to some customizations. Otherwise,
|
||||
|
Loading…
Reference in New Issue
Block a user