No project description provided
Project description
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 details)
Built Distribution
File details
Details for the file pytest-ngrok-0.0.1.tar.gz
.
File metadata
- Download URL: pytest-ngrok-0.0.1.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 974407364e99481a26fcacc8b3941af0b4ace3c3212ed341aad7ac6b2b30410e |
|
MD5 | a4bd4083a9a846b31691484762c9808b |
|
BLAKE2b-256 | 30aea2f18e63e18b3ef96af6c98c4ff82a9781fbe04ed5a7eb2cb4f1e17173f0 |
File details
Details for the file pytest_ngrok-0.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_ngrok-0.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4355f33fdf525194c5116644686c2ba0edf419765837e58f2b7faa37cf474ee1 |
|
MD5 | 36321459583a97750be71f47a46be105 |
|
BLAKE2b-256 | 70887dcf93919083b783f87b3f0bf4a0dec94dc95e4afc49a16398172da81a7a |