Skip to main content

No project description provided

Project description

Build Status codecov Requirements Status PyUP PyPI

pytest integration for ngrok

Installation

or from git

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

Usage

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)

With pytest-django can use fixture live_server_ngrok

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

Fixtures

fixture lookup binary ngrok in $PATH or download binary to $HOME/.local/bin/ngrok by default.

for override it use ngrok_bin fixture

import pytest

@pytest.fixture()
def ngrok_bin():
    return '/path/to/writable/bin/ngrok'

Contributing

run example app

pip install -r requirements-dev.txt

run tests

pip install -r requirements-dev.txt
pytest
tox

Update version

python setup.py bumpversion

publish pypi

python setup.py publish

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-ngrok-0.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

pytest_ngrok-0.0.1-py2.py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page