From aeaba06bf4976cca2d97f7a39de86a385f6af777 Mon Sep 17 00:00:00 2001 From: Justin Bronn Date: Sun, 19 Apr 2009 22:49:15 +0000 Subject: [PATCH] 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 --- django/contrib/gis/tests/__init__.py | 45 ++++------------------------ 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/django/contrib/gis/tests/__init__.py b/django/contrib/gis/tests/__init__.py index 4baa77ab43..566dc4f423 100644 --- a/django/contrib/gis/tests/__init__.py +++ b/django/contrib/gis/tests/__init__.py @@ -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 - - Or you may alter the user's role from the SQL shell (assuming this - is done from an existing superuser role): - postgres# ALTER ROLE 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,