Explorar el Código

Tests passing without django installed

Ask Solem hace 8 años
padre
commit
5fcb338b4b
Se han modificado 1 ficheros con 10 adiciones y 7 borrados
  1. 10 7
      t/unit/fixups/test_django.py

+ 10 - 7
t/unit/fixups/test_django.py

@@ -242,13 +242,16 @@ class test_DjangoWorkerFixup(FixupCase):
                 f.on_worker_ready()
 
     def test_validate_models(self, patching):
-        f = self.Fixup(self.app)
-        f.django_setup = Mock(name='django.setup')
-        patching.modules('django.core.checks')
-        from django.core.checks import run_checks
-        f.validate_models()
-        f.django_setup.assert_called_with()
-        run_checks.assert_called_with()
+        with mock.module('django', 'django.db', 'django.core',
+                         'django.core.cache', 'django.conf',
+                         'django.db.utils'):
+            f = self.Fixup(self.app)
+            f.django_setup = Mock(name='django.setup')
+            patching.modules('django.core.checks')
+            from django.core.checks import run_checks
+            f.validate_models()
+            f.django_setup.assert_called_with()
+            run_checks.assert_called_with()
 
     def test_django_setup(self, patching):
         patching('celery.fixups.django.symbol_by_name')