I have the following import line in a Django 1.4 project running in Python 2.7.6:
from django.contrib.gis.utils import GeoIP
This line only works 100% of the time in production and in development, but this line does not work with TestError in the test - sometimes. Given the following dummy test:
from django.test import TestCase
from django.test.client import Client
class DummyTestCase(TestCase):
def test_GET_200_response_code(self):
c = Client()
response = c.get('/')
self.assertEqual(response.status_code, 200)
If I run only those tests in this module, it does not work on the line response = self.c.get('/'):
...
File "...", line 19, in <module>
from django.contrib.gis.utils import GeoIP
ImportError: cannot import name GeoIP
However , when I run the entire test suite, including the same test, it passes without problems. And, again, the import works fine in the console, as well as on the server in dev and production.
So ... why is this happening? Why should I get ImportError only when I run this single test module and never otherwise, even if I run all the tests, including this module?
. Django 1.4 . , from django.contrib.gis.geoip import GeoIP, utils 1.4, 1.6. , , .