ivy*_*ivy 6 django jenkins phantomjs casperjs ghost.py
我写了一些casperjs测试来测试我的Django应用程序.如果启动Django应用程序(例如,在端口8000上),则casperjs可以作为单独的进程运行并访问我正在运行的Django应用程序.
我的其他测试是用Django(web)测试框架编写的,该框架使用fixture设置测试数据库,并运行./manage.py test.使用Django webtest,您不需要启动单独的Django Web服务器(执行请求和URL路由是代理/模拟的).
有没有办法从Django webtest中调整casperjs测试?没有启动不同的网络服务器和另一个测试数据库?
我见过ghost.py存在,但尚未尝试过.
我已经设法找到解决方案。升级到 Django 1.4 后,我可以在子进程中使用 LiveServerTestCase 和 fork casperjs:
from django.test.testcases import LiveServerTestCase
import os, subprocess
from subprocess import Popen, PIPE, STDOUT
class CasperTest(LiveServerTestCase):
fixtures = ['test_initial_data', ]
def test_my_testcase(self):
p = Popen(['casperjs %s/caspertest.js' % os.path.dirname(__file__)], shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
output = p.stdout.read()
print output
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1133 次 |
| 最近记录: |