Django

Code

Changeset 6413

Show
Ignore:
Timestamp:
09/24/07 15:29:27 (1 year ago)
Author:
jbronn
Message:

gis: modifed tests and mixin to use the HAS_GDAL flag.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis/django/contrib/gis/db/models/mixin.py

    r6188 r6413  
    11from warnings import warn 
    22 
    3 # GEOS is a requirement 
     3# GEOS is a requirement, GDAL is not 
    44from 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: 
     5from django.contrib.gis.gdal import HAS_GDAL 
     6if HAS_GDAL: 
    97    from django.contrib.gis.gdal import OGRGeometry, SpatialReference 
    10     HAS_GDAL = True 
    11 except ImportError, e: 
    12     HAS_GDAL = False 
    138 
    149# Until model subclassing is a possibility, a mixin class is used to add 
  • django/branches/gis/django/contrib/gis/tests/__init__.py

    r6240 r6413  
     1import sys 
    12from copy import copy 
    23from unittest import TestSuite, TextTestRunner 
    3 import sys 
     4from django.contrib.gis.gdal import HAS_GDAL 
     5 
    46 
    57# Tests that do not require setting up and tearing down a spatial database. 
     
    810    'test_measure', 
    911] 
    10 try: 
    11     # GDAL tests 
    12     import django.contrib.gis.gdal 
     12if HAS_GDAL: 
    1313    test_suite_names += [ 
    1414        'test_gdal_driver', 
     
    1717        'test_gdal_srs', 
    1818        'test_spatialrefsys', 
    19    
    20 except ImportError, e: 
     19       
     20else: 
    2121    print >>sys.stderr, "GDAL not available - no GDAL tests will be run." 
    2222 
     
    3636 
    3737def 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. 
    4041     
    4142    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 need 
    46             to use a different TCP port than 5432. Edit postgresql.conf (in  
    47             /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` 
    4950 
    5051    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. 
    5354       
    5455    In settings.py set TEST_RUNNER='django.contrib.gis.tests.run_tests'. 
    5556 
    5657    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. 
    5960 
    6061    The tests may be run by invoking `./manage.py test`.