一个简单的库,将wsgi应用程序包装在一个适合用selenium webdriver进行单元测试的环境中
selwsgi的Python项目详细描述
一个简单的库,将wsgi应用程序包装在一个适合用selenium webdriver进行单元测试的环境中。
安装
安装代码的最简单方法是使用pip。
从PyPI安装最新版本。
pip install selwsgi
安装最新的开发版本:
pip install git+https://github.com/freyes/selenium-webdriver-wsgi.git#egg=selwsgi
另一个选项是手动下载和解压代码并执行 包括安装脚本:
./setup.py install
示例用法
简单单元测试示例:
from selwsgi import WebDriverApp from nose.tools import assert_true from myapp import application class BaseTestSelenium(object): def setUp(self): self.app = WebDriverApp(application()) def tearDown(self): self.app.close() def test_index(self): res = self.app.get("/") assert_true(res.headers["Location"].endswith("/account/login?next=%2F"), "Location ({}) doesn't end with /account/login?next=%2F".format(res.headers["Location"]))