mardi 20 septembre 2016

django celery unit tests with pycharm 'No module named celery'

my tests work fine when my target is a single function (see 'Target' field in the image):

questionator.test_mturk_views.TestReport.submit

However, when I specify my target to include all tests within my questionator app:

questionator

I get this error:

Error ImportError: Failed to import test module: src.questionator.test_mturk_views Traceback (most recent call last):
File "C:\Python27\Lib\unittest\loader.py", line 254, in _find_tests module = self._get_module_from_name(name) File "C:\Python27\Lib\unittest\loader.py", line 232, in _get_module_from_name import(name) File "C:\Users\Andy\questionator_app\src__init__.py", line 5, in from .celery import app as celery_app # noqa ImportError: No module named celery

Note that my tests include my settings via 'Environment variables' (see this in the pic too):

DJANGO_SETTINGS_MODULE=questionator_app.settings.development;PYTHONUNBUFFERED=1

The celery documentation mentions a "Using a custom test runner to test with celery" but this is in the now defunct djcelery package. I did though copy/paste/tweak this mentioned test runner and used it as described, but I get the same error.

Unfortunately using CELERY_ALWAYS_EAGER also does not work http://ift.tt/2cDXjBz

I would appreciate some guidance. With best wishes, Andy.

enter image description here

Aucun commentaire:

Enregistrer un commentaire