Skip to main content

未提供项目描述

项目描述

文件状态

词 编解码器

派皮 PyPI Python 版本 执照

ngrok.io 的pytest集成

安装

来自 PyPi

pip install pytest-ngrok

或来自 git

pip install -e git+https://githib.com/Apkawa/pytest-ngrok.git#egg=pytest-ngrok

用法

import pytest

from urllib.error import HTTPError
from urllib.request import urlopen

def test_ngrok(ngrok, httpserver):
    httpserver.expect_request("/foobar").respond_with_data("ok")
    remote_url = ngrok(httpserver.port)
    assert urlopen(remote_url + "/foobar").read() == b'ok'


def test_ngrok_context_manager(ngrok, httpserver):
    # example local server
    httpserver.expect_request("/foobar").respond_with_data("ok")
    with ngrok(httpserver.port) as remote_url:
        _test_url = str(remote_url) + '/foobar'
        assert urlopen(_test_url).read() == b'ok'

    # Connection closes
    pytest.raises(HTTPError, urlopen, _test_url)

pytest-django可使用夹具live_server_ngrok

def test_server(live_server_ngrok):
    assert live_server_ngrok.url.endswith('ngrok.io')

贡献

初始化

python -m venv /tmp/.venv/pytest-ngrok
source /tmp/.venv/pytest-ngrok/activate
pip install -r requirements-dev.txt

运行测试

pytest
tox

更新版本

python setup.py bumpversion

发布 pypi

python setup.py publish

项目详情


下载文件

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

源分布

pytest-ngrok-0.0.4.tar.gz (6.0 kB 查看哈希)

已上传 source

内置分布

pytest_ngrok-0.0.4-py2.py3-none-any.whl (6.9 kB 查看哈希)

已上传 py2 py3