[Python-modules-commits] [django-celery] 05/10: Fix_autodiscover for Django 1.7
Michael Fladischer
fladi at moszumanska.debian.org
Mon Oct 19 07:17:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
fladi pushed a commit to annotated tag debian/3.1.17-1
in repository django-celery.
commit f0efa969284b71245f1640d8e2687b58a5bec51d
Author: Brian May <bam at debian.org>
Date: Thu Oct 8 08:50:27 2015 -0700
Fix_autodiscover for Django 1.7
Bug-Vendor: https://github.com/celery/django-celery/issues/343
Last-Update: 2014-04-01
Patch-Name: fix_autodiscover.patch
---
djcelery/loaders.py | 9 +++++++--
djcelery/tests/test_discovery.py | 22 ++++++++++++++++------
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/djcelery/loaders.py b/djcelery/loaders.py
index df0a668..c86455a 100644
--- a/djcelery/loaders.py
+++ b/djcelery/loaders.py
@@ -175,8 +175,13 @@ def autodiscover():
return
_RACE_PROTECTION = True
try:
- return filter(None, [find_related_module(app, 'tasks')
- for app in settings.INSTALLED_APPS])
+ if django.VERSION < (1, 7):
+ return filter(None, [find_related_module(app, 'tasks')
+ for app in settings.INSTALLED_APPS])
+ else:
+ from django.apps import apps
+ return filter(None, [find_related_module(app.name, 'tasks')
+ for app in apps.get_app_configs()])
finally:
_RACE_PROTECTION = False
diff --git a/djcelery/tests/test_discovery.py b/djcelery/tests/test_discovery.py
index 22ebb4e..3b17d6c 100644
--- a/djcelery/tests/test_discovery.py
+++ b/djcelery/tests/test_discovery.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
import warnings
+import django
from django.conf import settings
from celery.registry import tasks
@@ -25,11 +26,20 @@ class TestDiscovery(unittest.TestCase):
def test_discovery_with_broken(self):
warnings.resetwarnings()
if 'someapp' in settings.INSTALLED_APPS:
- installed_apps = list(settings.INSTALLED_APPS)
- settings.INSTALLED_APPS = installed_apps + ['xxxnot.aexist']
- try:
+ if django.VERSION < (1, 7):
+ # Django < 1.7
+ installed_apps = list(settings.INSTALLED_APPS)
+ settings.INSTALLED_APPS = installed_apps + ['xxxnot.aexist']
+ try:
+ # we should get a warning when loading xxxnot.aexist
+ with warnings.catch_warnings(record=True) as log:
+ autodiscover()
+ self.assertTrue(log)
+ finally:
+ settings.INSTALLED_APPS = installed_apps
+ else:
+ # Django 1.7
with warnings.catch_warnings(record=True) as log:
+ # we should not get any warnings
autodiscover()
- self.assertTrue(log)
- finally:
- settings.INSTALLED_APPS = installed_apps
+ self.assertEqual(log, [])
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-celery.git
More information about the Python-modules-commits
mailing list