PyCharm 2.5 TestRunner cannot import a specific module

I upgraded to PyCharm 2.5 and in the meantime updated django-templated-email to version 0.4.3.

Now Django unit tests no longer work through PyCharm, since I get the error message ImportError: cannot import name send_templated_mail at the output of the test console.

When you run the same test in the console, this error does not appear. I have a feeling that this is due to the fact that send_templated_email is part of templated_email\__init__.py (I vaguely remember a similar problem once, but I can't let my life remember how I fixed it).

Settings in the test dialog box:

 Target: <django app name> Custom settings: <path to dev settings> Environment variables: PYTHONPATH: <path as set in virtualenv> Python interpreter: <virtualenv Python interpreter> Interpreter options: None Working directory: <path to Django project (where manage.py resides)> 

It is strange that code verification inside the IDE does not complain and loads the templated_email module correctly through from templated_email import send_templated_mail .

I am using Windows 7, and my Django application runs inside virtualenv (which is correctly recognized by PyCharm).

+6
source share
1 answer

I would suggest upgrading to version 4.5.x if you have not already done so. It fixes many bugs and has several improvements.

Also, if you think this is a bug in PyCharm, check their bug tracking / registration site:

https://youtrack.jetbrains.com/issues

0
source

Source: https://habr.com/ru/post/913200/


All Articles