django celery unit tests with pycharm 'No module named celery'
Question: 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](http://docs.celeryproject.org/projects/django-
celery/en/2.4/cookbook/unit-testing.html) 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](https://github.com/celery/django-
celery/blob/master/djcelery/contrib/test_runner.py%5C) and used it as
described, but I get the same error.

Unfortunately using CELERY_ALWAYS_EAGER also does not work
<http://docs.celeryproject.org/en/latest/configuration.html#celery-always-
eager>

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

[![enter image description
here](http://i.stack.imgur.com/KQTtS.png)](http://i.stack.imgur.com/KQTtS.png)


Answer: with-the-same-problem (most likely me),

I had followed the official
[tutorial](http://docs.celeryproject.org/en/latest/django/first-steps-with-
django.html) for getting celery working in my project. They advised the below:
[![enter image description
here](http://i.stack.imgur.com/gaOE3.png)](http://i.stack.imgur.com/gaOE3.png)

Just making the last import explicit solved my problem:

    
    
    from taskapp.celery import app as celery_app  # noqa
    

I'll see if I can nudge Celery's creators to update their tutorial ([pull
request](https://github.com/celery/celery/pull/3463)).

