Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.x] Lowered field ordering requirement in ogrinspect test

This test was randomly failing depending on the library environment.
Backport of a1c470a from master.
  • Loading branch information...
commit 3610d11ba06f242d409100fd456ecf22d3bfcf7f 1 parent 6bd3896
Claude Paroz claudep authored
Showing with 20 additions and 16 deletions.
  1. +20 −16 django/contrib/gis/tests/inspectapp/tests.py
36 django/contrib/gis/tests/inspectapp/tests.py
View
@@ -68,23 +68,27 @@ def test_time_field(self):
layer_key=AllOGRFields._meta.db_table,
decimal=['f_decimal'])
- expected = [
- '# This is an auto-generated Django model module created by ogrinspect.',
- 'from django.contrib.gis.db import models',
- '',
- 'class Measurement(models.Model):',
- ' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)',
- ' f_int = models.IntegerField()',
- ' f_datetime = models.DateTimeField()',
- ' f_time = models.TimeField()',
- ' f_float = models.FloatField()',
- ' f_char = models.CharField(max_length=10)',
- ' f_date = models.DateField()',
- ' geom = models.PolygonField()',
- ' objects = models.GeoManager()',
- ]
+ self.assertTrue(model_def.startswith(
+ '# This is an auto-generated Django model module created by ogrinspect.\n'
+ 'from django.contrib.gis.db import models\n'
+ '\n'
+ 'class Measurement(models.Model):\n'
+ ))
+
+ # The ordering of model fields might vary depending on several factors (version of GDAL, etc.)
+ self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def)
+ self.assertIn(' f_int = models.IntegerField()', model_def)
+ self.assertIn(' f_datetime = models.DateTimeField()', model_def)
+ self.assertIn(' f_time = models.TimeField()', model_def)
+ self.assertIn(' f_float = models.FloatField()', model_def)
+ self.assertIn(' f_char = models.CharField(max_length=10)', model_def)
+ self.assertIn(' f_date = models.DateField()', model_def)
+
+ self.assertTrue(model_def.endswith(
+ ' geom = models.PolygonField()\n'
+ ' objects = models.GeoManager()'
+ ))
- self.assertEqual(model_def, '\n'.join(expected))
def get_ogr_db_string():
# Construct the DB string that GDAL will use to inspect the database.
Please sign in to comment.
Something went wrong with that request. Please try again.