用于envjasmine的python包装器

pyenvjasmine的Python项目详细描述


这是一个围绕envjasminejavascript的瘦python包装器 测试框架。

Installation

您可以使用pip

pip install pyenvjasmine

或者您可以获取最新的源并从那里安装:

python setup.py install

另外,您可以直接从sources目录中使用它,在development mode (如果您想为项目做出贡献,这一点很有用):

pip install -e .

注意

有关开发模式的更多信息,请点击此处:

https://packaging.python.org/en/latest/distributing.html#working-in-development-mode

警告

从版本0.3.0开始,pyenvjasmine支持使用 不同的浏览器/引擎。无头浏览器rhino包含在 pyenvjasmine,但是为了使用其他引擎,必须安装 需要的浏览器。

现在,只支持phantomjs,因此请确保在 您想使用浏览器/引擎运行测试。如果需要 在jasmine 3.x上运行测试(也需要运行pyenvjasmine自己的 测试)。

Running pyenvjasmine tests

要在此代码上运行测试(与yourjavascript代码相反 要测试),请安装pyenvjasmine(和phantomjs),然后运行:

py.test

Run your own tests

最简单的方法是将“specs”(javascript测试)放到某个目录中 在代码中,然后在python测试中,只添加一个测试的新测试用例 运行所有javascript测试。

最简单的解决方案是将capture_output设置为false,这样就可以看到输出 从控制台上的js测试。像这样:

import pytest
from pyenvjasmine.runner import Runner

class TestJavaScript(object):
    def test_my_javascript(self):
        runner = Runner(
            testdir='/path/to/my/testdir',
            configfile='relative/path/to/configfile',
            testing_environment='phantomjs')
        success, stdout = runner.run()
        # assert on success, will be true if tests passed, False if any
        # test failed
        assert success, "One or more javascript tests have failed"
        # you can inspect stdout if you want to get more info, but it
        # will be printed to the console stdout anyway
        assert b'Total: 120' in stdout

在本例中,使用phantomjs浏览/引擎,将其替换为 rhino在rhino+jasmine 1.x上运行测试。

注意

phantomjs是首选的浏览器/引擎,所以这就是pyenvjasmine 如果在创建 一个新的runner实例。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
在Java中使用工厂设计模式   解析服务器安全性的java最佳实践   java如何解决由于某种原因导致的执行失败?   关于Servlet的java   如何在java中生成一个大的(30MB+)xml文件?   匿名类重写与传递接口,用于在Java中设计回调   java jar从运行时开始。getRuntime()。exec()比从命令行运行的时间长   java Ant脚本排除文件夹(某些文件除外)   java在Windows 10计算机上运行时遇到Maven错误   java Hibernate在同一个表中级联   java PayPal API设置返回URL   java如何在选项卡的右侧显示关闭按钮   当按下Jmenu按钮时,使用java操作侦听器退出程序