我正在尝试测试我的django项目,我有一个应用程序,布局非常经典,如下所示:
project
├── __init__.py
└── app
├── __init__.py
├── models.py
├── tests
│ ├── __init__.py
│ ├── models.py
│ └── views.py
└── views.py将manage.py放在manage.py的父目录中(根据Django1.4的新布局)。
在test/__init__.py中,我有类似的东西:
from project.app.tests.models import *
from project.app.tests.views import *在test/models.py中,我有经典的python测试(它们工作得很好),在test/views.py中,我有selenium测试。
现在,当我这样做的时候:
python manage.py test project/app/tests/views.pyselenium测试可以正常工作,没有任何问题(虽然目前它们失败了,但我正在努力)。但当我这么做的时候:
python manage.py test project/app一些常规测试是正确启动的,但是在某些时候,firefox启动了,所有的东西都冻结了,没有更多的测试启动了,firefox和终端都没有发生任何事情。
我要补充的是,我的常规测试派生自unittest.TestCase (而不是django.test.TestCase),我的selenium测试派生自django.test.LiveServerTestCase,并且我使用的是django 1.4.0、nose 1.2.1、django-nas1.1和selenium 2.26.0。
有什么线索吗?
发布于 2012-11-23 03:33:07
如果您正在使用selenium的wait methods,那么在满足特定条件之前,测试可能会被阻塞。请参阅上面的webdriver文档。
发布于 2013-06-13 17:28:03
我在某处读到(忘了这篇文章的来源),你正在使用的组合需要一个sqlite (TEST_NAME)的测试数据库别名。并且不使用内存中的sqlite数据库。不确定您在测试时使用的是哪个数据库,但这些信息可能会有所帮助?
我把这个放在我的开发设置中:
DATABASES = {
'default': {
'NAME': os.path.join(BUILDOUT_DIR, 'var', 'sqlite', 'development.db'),
# TEST_NAME is absolutely CRITICAL for getting django-nose-selenium
# going with sqlite3. The default in-memory breaks everything.
'TEST_NAME': os.path.join(BUILDOUT_DIR, 'var', 'sqlite', 'unittest.db'),
'ENGINE': 'django.db.backends.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '', # empty string for localhost.
'PORT': '', # empty string for default.
}
}https://stackoverflow.com/questions/13517202
复制相似问题