Changeset 6413
- Timestamp:
- 09/24/07 15:29:27 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis/django/contrib/gis/db/models/mixin.py
r6188 r6413 1 1 from warnings import warn 2 2 3 # GEOS is a requirement 3 # GEOS is a requirement, GDAL is not 4 4 from django.contrib.gis.geos import GEOSGeometry 5 6 # GDAL is a lot more complicated to install, and isn't necessary for many 7 # operations. 8 try: 5 from django.contrib.gis.gdal import HAS_GDAL 6 if HAS_GDAL: 9 7 from django.contrib.gis.gdal import OGRGeometry, SpatialReference 10 HAS_GDAL = True11 except ImportError, e:12 HAS_GDAL = False13 8 14 9 # Until model subclassing is a possibility, a mixin class is used to add django/branches/gis/django/contrib/gis/tests/__init__.py
r6240 r6413 1 import sys 1 2 from copy import copy 2 3 from unittest import TestSuite, TextTestRunner 3 import sys 4 from django.contrib.gis.gdal import HAS_GDAL 5 4 6 5 7 # Tests that do not require setting up and tearing down a spatial database. … … 8 10 'test_measure', 9 11 ] 10 try: 11 # GDAL tests 12 import django.contrib.gis.gdal 12 if HAS_GDAL: 13 13 test_suite_names += [ 14 14 'test_gdal_driver', … … 17 17 'test_gdal_srs', 18 18 'test_spatialrefsys', 19 ]20 e xcept ImportError,e:19 ] 20 else: 21 21 print >>sys.stderr, "GDAL not available - no GDAL tests will be run." 22 22 … … 36 36 37 37 def run_tests(module_list, verbosity=1, interactive=True): 38 """Run the tests that require creation of a spatial database. Does not 39 yet work on Windows platforms. 38 """ 39 Run the tests that require creation of a spatial database. Does not 40 yet work on Windows platforms. 40 41 41 42 In order to run geographic model tests the DATABASE_USER will require 42 superuser priviliges. To accomplish this outside the `postgres` user,43 create your own PostgreSQL database as a user:44 (1) Initialize database: `initdb -D /path/to/user/db`45 (2) If there's already a Postgres instance on the machine, it will need46 to use a different TCP port than 5432. Edit postgresql.conf (in47 /path/to/user/db) to change the database port (e.g. `port = 5433`).48 (3) Start this database `pg_ctl -D /path/to/user/db start`43 superuser priviliges. To accomplish this outside the `postgres` user, 44 create your own PostgreSQL database as a user: 45 (1) Initialize database: `initdb -D /path/to/user/db` 46 (2) If there's already a Postgres instance on the machine, it will need 47 to use a different TCP port than 5432. Edit postgresql.conf (in 48 /path/to/user/db) to change the database port (e.g. `port = 5433`). 49 (3) Start this database `pg_ctl -D /path/to/user/db start` 49 50 50 51 Make sure your settings.py matches the settings of the user database. For example, set the 51 same port number (`DATABASE_PORT=5433`). DATABASE_NAME or TEST_DATABSE_NAME must be set,52 along with DATABASE_USER.52 same port number (`DATABASE_PORT=5433`). DATABASE_NAME or TEST_DATABSE_NAME must be set, 53 along with DATABASE_USER. 53 54 54 55 In settings.py set TEST_RUNNER='django.contrib.gis.tests.run_tests'. 55 56 56 57 Finally, this assumes that the PostGIS SQL files (lwpostgis.sql and spatial_ref_sys.sql) 57 are installed in /usr/local/share. If they are not, add `POSTGIS_SQL_PATH=/path/to/sql`58 in your settings.py.58 are installed in /usr/local/share. If they are not, add `POSTGIS_SQL_PATH=/path/to/sql` 59 in your settings.py. 59 60 60 61 The tests may be run by invoking `./manage.py test`.
