celery / kombu

Messaging library for Python.
http://kombu.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
2.82k stars 921 forks source link

Pytest config conflicting with pytest-django plugin ? #664

Open ldng opened 7 years ago

ldng commented 7 years ago

Maybe it is a misconfiguration on my end but I'm having a conflict between kombu pytest config and my config using pytest-django.

A clue, might be something similar to a bug that was in django-assets ? See https://github.com/pytest-dev/pytest-django/issues/119 Then again, maybe not.

pyenv/lib/python3.5/site-packages/kombu/utils/__init__.py:323: in __get__
    return obj.__dict__[self.__name__]
E   KeyError: 'conf'

During handling of the above exception, another exception occurred:
pyenv/lib/python3.5/site-packages/py/_path/local.py:650: in pyimport
    __import__(modname)
valuation/__init__.py:10: in <module>
    local_celery_app.conf.update(CELERY_DISABLE_RATE_LIMITS=True)
pyenv/lib/python3.5/site-packages/kombu/utils/__init__.py:325: in __get__
    value = obj.__dict__[self.__name__] = self.__get(obj)
pyenv/lib/python3.5/site-packages/celery/app/base.py:638: in conf
    return self._get_config()
pyenv/lib/python3.5/site-packages/celery/app/base.py:454: in _get_config
    self.loader.config_from_object(self._config_source)
pyenv/lib/python3.5/site-packages/celery/loaders/base.py:145: in config_from_object
    self._conf = force_mapping(obj)
pyenv/lib/python3.5/site-packages/celery/datastructures.py:50: in force_mapping
    if isinstance(m, (LazyObject, LazySettings)):
pyenv/lib/python3.5/site-packages/django/utils/functional.py:234: in inner
    self._setup()
pyenv/lib/python3.5/site-packages/django/conf/__init__.py:39: in _setup
    % (desc, ENVIRONMENT_VARIABLE))
E   django.core.exceptions.ImproperlyConfigured: Requested settings, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
ask commented 7 years ago

Yeah, it's very annoying but I have to uninstall pytest-django when executing the Celery and Kombu test suites because pytest-django's detection of a Django project is flawed :(

bluetech commented 6 years ago

If you don't use the celery pytest support, you can workaround this issue by disabling it in the pytest configuration:

addopts = -p no:celery