Author: jbronn
Date: 2007-09-24 15:29:27 -0500 (Mon, 24 Sep 2007)
New Revision: 6413

Modified:
   django/branches/gis/django/contrib/gis/db/models/mixin.py
   django/branches/gis/django/contrib/gis/tests/__init__.py
Log:
gis: modifed tests and mixin to use the HAS_GDAL flag.


Modified: django/branches/gis/django/contrib/gis/db/models/mixin.py
===================================================================
--- django/branches/gis/django/contrib/gis/db/models/mixin.py   2007-09-24 
20:28:23 UTC (rev 6412)
+++ django/branches/gis/django/contrib/gis/db/models/mixin.py   2007-09-24 
20:29:27 UTC (rev 6413)
@@ -1,15 +1,10 @@
 from warnings import warn
 
-# GEOS is a requirement
+# GEOS is a requirement, GDAL is not
 from django.contrib.gis.geos import GEOSGeometry
-
-# GDAL is a lot more complicated to install, and isn't necessary for many
-# operations.
-try:
+from django.contrib.gis.gdal import HAS_GDAL
+if HAS_GDAL:
     from django.contrib.gis.gdal import OGRGeometry, SpatialReference
-    HAS_GDAL = True
-except ImportError, e:
-    HAS_GDAL = False
 
 # Until model subclassing is a possibility, a mixin class is used to add
 # the necessary functions that may be contributed for geographic objects.

Modified: django/branches/gis/django/contrib/gis/tests/__init__.py
===================================================================
--- django/branches/gis/django/contrib/gis/tests/__init__.py    2007-09-24 
20:28:23 UTC (rev 6412)
+++ django/branches/gis/django/contrib/gis/tests/__init__.py    2007-09-24 
20:29:27 UTC (rev 6413)
@@ -1,23 +1,23 @@
+import sys
 from copy import copy
 from unittest import TestSuite, TextTestRunner
-import sys
+from django.contrib.gis.gdal import HAS_GDAL
 
+
 # Tests that do not require setting up and tearing down a spatial database.
 test_suite_names = [
     'test_geos',
     'test_measure',
 ]
-try:
-    # GDAL tests
-    import django.contrib.gis.gdal
+if HAS_GDAL:
     test_suite_names += [
         'test_gdal_driver',
         'test_gdal_ds',
         'test_gdal_geom',
         'test_gdal_srs',
         'test_spatialrefsys',
-    ]
-except ImportError, e:
+        ]
+else:
     print >>sys.stderr, "GDAL not available - no GDAL tests will be run."
 
 test_models = ['geoapp']
@@ -35,27 +35,28 @@
     TextTestRunner(verbosity=verbosity).run(suite())
 
 def run_tests(module_list, verbosity=1, interactive=True):
-    """Run the tests that require creation of a spatial database.  Does not
-      yet work on Windows platforms.
+    """
+    Run the tests that require creation of a spatial database.  Does not
+     yet work on Windows platforms.
     
     In order to run geographic model tests the DATABASE_USER will require
-      superuser priviliges.  To accomplish this outside the `postgres` user,
-      create your own PostgreSQL database as a 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`
+     superuser priviliges.  To accomplish this outside the `postgres` user,
+     create your own PostgreSQL database as a 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`
 
     Make sure your settings.py matches the settings of the user database. For 
example, set the 
-      same port number (`DATABASE_PORT=5433`).  DATABASE_NAME or 
TEST_DATABSE_NAME must be set,
-      along with DATABASE_USER.
+     same port number (`DATABASE_PORT=5433`).  DATABASE_NAME or 
TEST_DATABSE_NAME must be set,
+     along with DATABASE_USER.
       
     In settings.py set TEST_RUNNER='django.contrib.gis.tests.run_tests'.
 
     Finally, this assumes that the PostGIS SQL files (lwpostgis.sql and 
spatial_ref_sys.sql)
-      are installed in /usr/local/share.  If they are not, add 
`POSTGIS_SQL_PATH=/path/to/sql`
-      in your settings.py.
+     are installed in /usr/local/share.  If they are not, add 
`POSTGIS_SQL_PATH=/path/to/sql`
+     in your settings.py.
 
     The tests may be run by invoking `./manage.py test`.
     """


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to