2015-08-28 61 views
0

在Django的1.8,我有一个应用程序使用此设置:测试在子目录

app 
|- tests/ 
| |- test_ook.py 
| |- __init__.py 
|- models.py 
|- __init__.py 
... 

当我运行python manage.py test -v 2 app,我得到这个错误:

ImportError: 'tests' module incorrectly imported from '/home/.../site/app/tests'. Expected '/home/.../site/app'. Is this module globally installed? 

这是为什么?

我该如何解决?

+1

请检查'app'中是否有'tests.py'或'tests.pyc'文件,即与'tests'模块处于同一级别。 –

回答

5

此错误,如果你有tests.py或存在于apptests.pyc文件在相同的水平tests模块一般发生。

删除这些文件,它应该完美工作。