Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Lowered field ordering requirement in ogrinspect test

This test was randomly failing depending on the library environment.
  • Loading branch information...
commit a1c470a6f6084ee3d803d884b62df61ab6f5c5df 1 parent 1f8e7bb
Claude Paroz authored February 02, 2013
56  django/contrib/gis/tests/inspectapp/tests.py
@@ -4,7 +4,7 @@
4 4
 
5 5
 from django.db import connections
6 6
 from django.test import TestCase
7  
-from django.contrib.gis.gdal import Driver, GDAL_VERSION
  7
+from django.contrib.gis.gdal import Driver
8 8
 from django.contrib.gis.geometry.test_data import TEST_DATA
9 9
 from django.contrib.gis.utils.ogrinspect import ogrinspect
10 10
 
@@ -70,41 +70,27 @@ def test_time_field(self):
70 70
                                layer_key=AllOGRFields._meta.db_table,
71 71
                                decimal=['f_decimal'])
72 72
 
73  
-        expected = [
74  
-            '# This is an auto-generated Django model module created by ogrinspect.',
75  
-            'from django.contrib.gis.db import models',
76  
-            '',
77  
-            'class Measurement(models.Model):',
78  
-            '    f_decimal = models.DecimalField(max_digits=0, decimal_places=0)',
79  
-        ]
80  
-
81  
-        if GDAL_VERSION < (1, 9, 0):
82  
-            # Prior to GDAL 1.9, the order of the model fields was not
83  
-            # the same as the columns in the database.
84  
-            expected.extend([
85  
-            '    f_int = models.IntegerField()',
86  
-            '    f_datetime = models.DateTimeField()',
87  
-            '    f_time = models.TimeField()',
88  
-            '    f_float = models.FloatField()',
89  
-            '    f_char = models.CharField(max_length=10)',
90  
-            '    f_date = models.DateField()',
91  
-            ])
92  
-        else:
93  
-            expected.extend([
94  
-            '    f_float = models.FloatField()',
95  
-            '    f_int = models.IntegerField()',
96  
-            '    f_char = models.CharField(max_length=10)',
97  
-            '    f_date = models.DateField()',
98  
-            '    f_datetime = models.DateTimeField()',
99  
-            '    f_time = models.TimeField()',
100  
-            ])
101  
-
102  
-        expected.extend([
103  
-            '    geom = models.PolygonField()',
104  
-            '    objects = models.GeoManager()',
105  
-        ])
  73
+        self.assertTrue(model_def.startswith(
  74
+            '# This is an auto-generated Django model module created by ogrinspect.\n'
  75
+            'from django.contrib.gis.db import models\n'
  76
+            '\n'
  77
+            'class Measurement(models.Model):\n'
  78
+        ))
  79
+
  80
+        # The ordering of model fields might vary depending on several factors (version of GDAL, etc.)
  81
+        self.assertIn('    f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def)
  82
+        self.assertIn('    f_int = models.IntegerField()', model_def)
  83
+        self.assertIn('    f_datetime = models.DateTimeField()', model_def)
  84
+        self.assertIn('    f_time = models.TimeField()', model_def)
  85
+        self.assertIn('    f_float = models.FloatField()', model_def)
  86
+        self.assertIn('    f_char = models.CharField(max_length=10)', model_def)
  87
+        self.assertIn('    f_date = models.DateField()', model_def)
  88
+
  89
+        self.assertTrue(model_def.endswith(
  90
+            '    geom = models.PolygonField()\n'
  91
+            '    objects = models.GeoManager()'
  92
+        ))
106 93
 
107  
-        self.assertEqual(model_def, '\n'.join(expected))
108 94
 
109 95
 def get_ogr_db_string():
110 96
     # Construct the DB string that GDAL will use to inspect the database.

0 notes on commit a1c470a

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