Skip to main content

envjasmine 的 Python 包装器

项目描述

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

<nav class="contents" id="contents" role="doc-toc">

内容

</nav>

安装

您可以使用pip安装 pyenvjasmine :

pip install pyenvjasmine

或者您可以使用Mercurialhttps://code.codigo23.net/hg/pyenvjasmine获取最新资源:

hg clone https://code.codigo23.net/hg/pyenvjasmine

并从那里安装它:

python setup.py install

此外,您可以在开发模式下直接从源目录中使用它 (如果您想为项目做出贡献,这很有用):

pip install -e .

运行 pyenvjasmine 测试

要在此处运行此代码的测试(而不是要测试的 JavaScript 代码),请安装 pyenvjasmine(和 phantomjs),然后运行:

py.test

运行您自己的测试

最简单的方法是将“规范”(JavaScript 测试)放入代码中的某个目录,然后在 python 测试中,添加一个新的 TestCase,其中只有一个运行所有 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 上运行测试。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

pyenvjasmine-0.3.1.tar.gz (2.3 MB 查看哈希

已上传 source

内置分布

pyenvjasmine-0.3.1-py3-none-any.whl (2.4 MB 查看哈希

已上传 py3