From 4c043c526e516d04709b0e507ad44ff40a6660e4 Mon Sep 17 00:00:00 2001 From: Steven Day Date: Thu, 5 Nov 2015 16:28:56 +0000 Subject: [PATCH] Forcefully register GDAL driver in import command tests To Workaround a Django bug here: https://github.com/django/django/blob/b35adb0909b25a7dafc9212ddedfbf9b29dc05b8/django/contrib/gis/gdal/driver.py#L81-L83 which should be guarded by two separate checks of the driver_count, not a single combined one. --- mapit/tests/test_import_commands.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mapit/tests/test_import_commands.py b/mapit/tests/test_import_commands.py index b4d3e9e2..c42ebe60 100644 --- a/mapit/tests/test_import_commands.py +++ b/mapit/tests/test_import_commands.py @@ -4,6 +4,7 @@ from django.core.management import call_command from django.conf import settings from django.utils.six import StringIO +from django.contrib.gis.gdal.prototypes import ds from ..models import Type, NameType, Area, Generation, Country @@ -11,6 +12,13 @@ class MapitImportTest(TestCase): """Test the mapit_import management command""" + def setUp(self): + # Forcefully register a GDAL datasource driver, because Django has a + # bug where it assumes that any existing drivers mean they're all + # available, which doesn't seem to be the case. + if not ds.get_driver_count(): + ds.register_all() + def test_loads_kml_files(self): # Assert no areas in db before self.assertEqual(Area.objects.count(), 0)