Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Replaced proj4 testing by a regex

  • Loading branch information...
commit 8a92139d8a5c2ecb4a7a55da74d293c71390e9ed 1 parent cbfb8ed
Claude Paroz authored March 08, 2013
15  django/contrib/gis/tests/test_spatialrefsys.py
@@ -2,6 +2,7 @@
2 2
 from django.contrib.gis.gdal import HAS_GDAL
3 3
 from django.contrib.gis.tests.utils import (no_mysql, oracle, postgis,
4 4
     spatialite, HAS_SPATIALREFSYS, SpatialRefSys)
  5
+from django.utils import six
5 6
 from django.utils import unittest
6 7
 
7 8
 
@@ -10,9 +11,8 @@
10 11
              'auth_srid' : 4326,
11 12
              # Only the beginning, because there are differences depending on installed libs
12 13
              'srtext' : 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
13  
-             'proj4' : ['+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ',
14  
-                        # +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
15  
-                        '+proj=longlat +datum=WGS84 +no_defs '],
  14
+             # +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
  15
+             'proj4_re' : r'\+proj=longlat (\+ellps=WGS84 )?\+datum=WGS84 \+no_defs ',
16 16
              'spheroid' : 'WGS 84', 'name' : 'WGS 84',
17 17
              'geographic' : True, 'projected' : False, 'spatialite' : True,
18 18
              'ellipsoid' : (6378137.0, 6356752.3, 298.257223563), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
@@ -22,8 +22,9 @@
22 22
              'auth_name' : ('EPSG', False),
23 23
              'auth_srid' : 32140,
24 24
              'srtext' : 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"',
25  
-             'proj4' : ['+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +datum=NAD83 +units=m +no_defs ',
26  
-                        '+proj=lcc +lat_1=30.28333333333333 +lat_2=28.38333333333333 +lat_0=27.83333333333333 +lon_0=-99 +x_0=600000 +y_0=4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs '],
  25
+             'proj4_re' : r'\+proj=lcc \+lat_1=30.28333333333333 \+lat_2=28.38333333333333 \+lat_0=27.83333333333333 '
  26
+                          r'\+lon_0=-99 \+x_0=600000 \+y_0=4000000 \+ellps=GRS80 '
  27
+                          r'(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0)?\+units=m \+no_defs ',
27 28
              'spheroid' : 'GRS 1980', 'name' : 'NAD83 / Texas South Central',
28 29
              'geographic' : False, 'projected' : True, 'spatialite' : False,
29 30
              'ellipsoid' : (6378137.0, 6356752.31414, 298.257222101), # From proj's "cs2cs -le" and Wikipedia (semi-minor only)
@@ -54,7 +55,7 @@ def test01_retrieve(self):
54 55
             # No proj.4 and different srtext on oracle backends :(
55 56
             if postgis:
56 57
                 self.assertTrue(srs.wkt.startswith(sd['srtext']))
57  
-                self.assertTrue(srs.proj4text in sd['proj4'])
  58
+                six.assertRegex(self, srs.proj4text, sd['proj4_re'])
58 59
 
59 60
     @no_mysql
60 61
     def test02_osr(self):
@@ -73,7 +74,7 @@ def test02_osr(self):
73 74
             # Testing the SpatialReference object directly.
74 75
             if postgis or spatialite:
75 76
                 srs = sr.srs
76  
-                self.assertTrue(srs.proj4 in sd['proj4'])
  77
+                six.assertRegex(self, srs.proj4, sd['proj4_re'])
77 78
                 # No `srtext` field in the `spatial_ref_sys` table in SpatiaLite
78 79
                 if not spatialite:
79 80
                     self.assertTrue(srs.wkt.startswith(sd['srtext']))

0 notes on commit 8a92139

Please sign in to comment.
Something went wrong with that request. Please try again.