我必须强调的PyCharm 社区版这也没有任何Django的集成(v 2016年3月2日在质询时间)。
Google已经解决了我的问题,并且(令人惊讶的是)我没有得到任何答案,(当然,我没有排除可能有答案的可能性,但是我只是错过了它们)。
问题很简单:在PyCharm中,只需单击鼠标右键(从上下文菜单中),就可以运行(调试)单元测试(TestCase或其方法之一),如下图所示:
在RClick上运行Django单元测试
不幸的是,这产生了一个例外:
Traceback (most recent call last):
File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 254, in <module>
main()
File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 232, in main
module = loadSource(a[0])
File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 65, in loadSource
module = imp.load_source(moduleName, fileName)
File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\tests.py", line 7, in <module>
from polls.models import Question
File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\models.py", line 9, in <module>
class Question(models.Model):
File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\models.py", line 10, in Question
question_text = models.CharField(max_length=200)
File "E:\Work\Dev\VEnvs\py2713x64-django\lib\site-packages\django\db\models\fields\__init__.py", line 1043, in __init__
super(CharField, self).__init__(*args, **kwargs)
File "E:\Work\Dev\VEnvs\py2713x64-django\lib\site-packages\django\db\models\fields\__init__.py", line 166, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "E:\Work\Dev\VEnvs\py2713x64-django\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "E:\Work\Dev\VEnvs\py2713x64-django\lib\site-packages\django\conf\__init__.py", line 39, in _setup
% (desc, ENVIRONMENT_VARIABLE)