Python django应用程序selenium测试没有静态文件

Python django应用程序selenium测试没有静态文件,python,django,selenium,Python,Django,Selenium,我想在我的django应用程序上做一些功能测试。我使用的是selenium,测试可以工作,但问题是静态文件。找不到css/js状态。 我的测试正在本地主机8081上运行。 示例bootstrap.css: <h1>Not Found</h1><p>The requested URL /static/frontend/bootstrap/3.3.0/css/bootstrap.css was not found on this server.</p>

我想在我的django应用程序上做一些功能测试。我使用的是selenium,测试可以工作,但问题是静态文件。找不到css/js状态。 我的测试正在本地主机8081上运行。 示例bootstrap.css:

<h1>Not Found</h1><p>The requested URL /static/frontend/bootstrap/3.3.0/css/bootstrap.css was not found on this server.</p>

好的,我找到了解决办法。首先,我必须添加设置

STATIC_ROOT = 'my static dir'
然后:

您可以使用 来自
django.contrib.staticfiles.testing

不仅要注意不同的类名,还要注意不同的模块名:

from django.test import LiveServerTestCase
#     ^-- vs --v
from django.contrib.staticfiles.testing import StaticLiveServerTestCase

谢谢,
LiveServerTestCase
使用生产设置(
DEBUG=True
),因此需要先收集静态文件。很清楚now@MartinM应该是
DEBUG=False
?救生员。我找到的所有selenium doco都是针对django 1.6的。
./manage.py collectstatic
from django.test import LiveServerTestCase
#     ^-- vs --v
from django.contrib.staticfiles.testing import StaticLiveServerTestCase