mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Lowered field ordering requirement in ogrinspect test
This test was randomly failing depending on the library environment.
This commit is contained in:
		| @@ -4,7 +4,7 @@ import os | |||||||
|  |  | ||||||
| from django.db import connections | from django.db import connections | ||||||
| from django.test import TestCase | from django.test import TestCase | ||||||
| from django.contrib.gis.gdal import Driver, GDAL_VERSION | from django.contrib.gis.gdal import Driver | ||||||
| from django.contrib.gis.geometry.test_data import TEST_DATA | from django.contrib.gis.geometry.test_data import TEST_DATA | ||||||
| from django.contrib.gis.utils.ogrinspect import ogrinspect | from django.contrib.gis.utils.ogrinspect import ogrinspect | ||||||
|  |  | ||||||
| @@ -70,41 +70,27 @@ class OGRInspectTest(TestCase): | |||||||
|                                layer_key=AllOGRFields._meta.db_table, |                                layer_key=AllOGRFields._meta.db_table, | ||||||
|                                decimal=['f_decimal']) |                                decimal=['f_decimal']) | ||||||
|  |  | ||||||
|         expected = [ |         self.assertTrue(model_def.startswith( | ||||||
|             '# This is an auto-generated Django model module created by ogrinspect.', |             '# This is an auto-generated Django model module created by ogrinspect.\n' | ||||||
|             'from django.contrib.gis.db import models', |             'from django.contrib.gis.db import models\n' | ||||||
|             '', |             '\n' | ||||||
|             'class Measurement(models.Model):', |             'class Measurement(models.Model):\n' | ||||||
|             '    f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', |         )) | ||||||
|         ] |  | ||||||
|  |  | ||||||
|         if GDAL_VERSION < (1, 9, 0): |         # The ordering of model fields might vary depending on several factors (version of GDAL, etc.) | ||||||
|             # Prior to GDAL 1.9, the order of the model fields was not |         self.assertIn('    f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def) | ||||||
|             # the same as the columns in the database. |         self.assertIn('    f_int = models.IntegerField()', model_def) | ||||||
|             expected.extend([ |         self.assertIn('    f_datetime = models.DateTimeField()', model_def) | ||||||
|             '    f_int = models.IntegerField()', |         self.assertIn('    f_time = models.TimeField()', model_def) | ||||||
|             '    f_datetime = models.DateTimeField()', |         self.assertIn('    f_float = models.FloatField()', model_def) | ||||||
|             '    f_time = models.TimeField()', |         self.assertIn('    f_char = models.CharField(max_length=10)', model_def) | ||||||
|             '    f_float = models.FloatField()', |         self.assertIn('    f_date = models.DateField()', model_def) | ||||||
|             '    f_char = models.CharField(max_length=10)', |  | ||||||
|             '    f_date = models.DateField()', |  | ||||||
|             ]) |  | ||||||
|         else: |  | ||||||
|             expected.extend([ |  | ||||||
|             '    f_float = models.FloatField()', |  | ||||||
|             '    f_int = models.IntegerField()', |  | ||||||
|             '    f_char = models.CharField(max_length=10)', |  | ||||||
|             '    f_date = models.DateField()', |  | ||||||
|             '    f_datetime = models.DateTimeField()', |  | ||||||
|             '    f_time = models.TimeField()', |  | ||||||
|             ]) |  | ||||||
|  |  | ||||||
|         expected.extend([ |         self.assertTrue(model_def.endswith( | ||||||
|             '    geom = models.PolygonField()', |             '    geom = models.PolygonField()\n' | ||||||
|             '    objects = models.GeoManager()', |             '    objects = models.GeoManager()' | ||||||
|         ]) |         )) | ||||||
|  |  | ||||||
|         self.assertEqual(model_def, '\n'.join(expected)) |  | ||||||
|  |  | ||||||
| def get_ogr_db_string(): | def get_ogr_db_string(): | ||||||
|     # Construct the DB string that GDAL will use to inspect the database. |     # Construct the DB string that GDAL will use to inspect the database. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user